- Introduction
- Prerequisites
- Installation
- Configuration
- Using the Extension
- Examples
- Additional Resources
- Contributing
- License
The Flutter l10m extension for Visual Studio Code automates the internationalization (i18n) process in Flutter projects that use the l10m package. It monitors changes in .arb files and executes specific commands to regenerate translations, facilitating the development of multilingual applications.
- Visual Studio Code installed.
- Flutter SDK configured and operational.
- A Flutter project set up to use the l10m package.
- Basic knowledge of internationalization in Flutter.
Installing the Extension:
- Open Visual Studio Code.
- Go to the Extensions tab (or press
Ctrl+Shift+X). - Search for "Flutter l10m".
- Click Install on the Flutter l10m extension.
The Flutter l10m extension requires minimal configuration to work correctly. It uses a command that will be executed whenever a .arb file is changed.
By default, the extension executes the following command:
dart run l10mYou can customize the command to be executed by modifying the l10m.command setting in the VSCode user or workspace settings.
-
Open Settings:
- Go to
File>Preferences>Settings(orCtrl+,).
- Go to
-
Search for "l10m":
- In the settings search bar, type
l10m.
- In the settings search bar, type
-
Modify the Command:
- Find the "Flutter l10m: Command" setting.
- Enter the desired command in the text field.
Example:
dart run l10m -m lib/custom_modules_folder
- In this example, the command specifies a custom modules path.
-mor--module-path: Specifies the modules path. Example:-m lib/modules.--no-generate-root: Indicates not to generate translations in the root folder.-gor--generate: Specifies the name of the module to generate. Example:-g user_profile.
After installation and configuration, the extension will work automatically.
- Monitoring
.arbFiles: The extension monitors changes in all files with the.arbextension in the project. - Automatic Command Execution: When a
.arbfile is modified, the extension executes the configured command, adapting it according to the changed file.
-
.arbFile in the Root Folder (lib/l10n):- If the changed file is in
lib/l10nand the--no-generate-rootoption is not present, the command will be executed with the--generate-only-rootparameter.
Executed Command:
dart run l10m --generate-only-root
- If the changed file is in
-
.arbFile in a Module:- If the changed file is in the modules path (by default,
lib/modules), the extension extracts the module name and executes the command with-g <module_name> --generate-only-module.
Executed Command:
dart run l10m -g module_name --generate-only-module
- If the changed file is in the modules path (by default,
-
Other Files:
- If the
.arbfile is not in any of the above paths, the extension executes the default configured command.
- If the
-
Scenario:
- You modified the file
lib/modules/user_profile/l10n/intl_en.arb.
- You modified the file
-
Extension Action:
-
The extension detects the change and identifies the
user_profilemodule. -
Executes the command:
dart run l10m -g user_profile --generate-only-module
-
-
Scenario:
- You modified the file
lib/l10n/intl_en.arb.
- You modified the file
-
Extension Action:
-
The extension recognizes that the file is in the root localization folder.
-
Executes the command:
dart run l10m --generate-only-root
-
-
Configuration:
-
In VSCode settings, you changed the command to:
dart run l10m -m lib/custom_modules --no-generate-root
-
-
Scenario:
- You modified the file
lib/custom_modules/shopping_cart/l10n/intl_en.arb.
- You modified the file
-
Extension Action:
-
The extension identifies the
shopping_cartmodule in the custom path. -
Executes the command:
dart run l10m -g shopping_cart --generate-only-module
-
-
l10m Package Documentation:
-
To better understand how the
l10mpackage works and its capabilities, refer to the official documentation:
-
-
Reporting Issues and Suggestions:
- If you encounter problems or have suggestions to improve the extension, please open an issue in the project's repository (add the repository link here).
Contributions are welcome! If you wish to contribute to the development of the extension:
-
Fork the Repository:
- Clone the repository to your GitHub account.
-
Create a Branch for Your Feature or Fix:
git checkout -b my-feature
-
Make the Necessary Changes and Tests.
-
Submit a Pull Request:
- Describe the changes made and await review.
This extension is distributed under the MIT license. Refer to the LICENSE file in the repository for more information.
-
Keeping the Extension Updated:
- Regularly check for updates to the extension in the VSCode Marketplace.
-
Compatibility:
- The extension has been tested on the latest versions of VSCode. If you encounter incompatibilities, please report them.
-
Support:
- For additional support, use the channels provided in the project's repository.
Thank you for using the Flutter l10m extension! We hope it makes the internationalization process in your Flutter projects more efficient and enjoyable.