How to Add/Remove a Language
Managing languages in your Flutter app allows users to switch between different languages seamlessly. Follow these steps to add or remove a language properly.
β How to Add a New Languageβ
π Step 1: Create a New Language Fileβ
-
Navigate to the following directory:
assets/languages/
-
Copy an existing JSON file (e.g.,
en.json
). -
Paste it into the same folder and rename it using the new language code (e.g.,
fr.json
for French).
βοΈ Step 2: Update the Language Stringsβ
- Open the newly created JSON file (
fr.json
). - Translate all the values into the new language.
- Important: Ensure all keys remain the same, only update the values.
Example (fr.json
for French):
{
"welcome_message": "Bonjour, Bienvenue!",
"logout": "DΓ©connexion"
}
π Step 3: Register the New Languageβ
-
Locate the language list in your project.
-
Add the language name, code, and flag image in the following list:
β How to Remove a Languageβ
- Remove the JSON file from assets/languages/.
- Delete the language entry from the language list.
β Your language settings are now updated! ππ