This is a simple example demonstrating how to use a JSON file for language switching in a web app. The project uses JavaScript to fetch translations from a JSON file and updates the text content of the page accordingly.
To get started, simply clone this repository and open the index.html file in your browser.
git clone https://github.com/golgetc/language-switcher-example.git
- The
lang.jsonfile contains translations for two languages: Turkish (tr) and English (en). - The JavaScript code in
index.htmlfetches the translations from the JSON file. - The text content of the page is updated based on the selected language.
- Clicking the "Change Language" button toggles between the two languages.
To customize the translations or add more languages, simply edit the lang.json file and update the JavaScript code in index.html accordingly.
This project is released under the MIT License. See LICENSE file for more details.