LAND is a powerful tool for generating localization files to be used in Dart applications, including Flutter apps. It supports complex ICU messages, works effectively even on non-Flutter applications, and offers multi-project support to simplify localization tasks in large codebases.
- Requirements
- Installation
- Using LAND
- Multi-Project Support
- Configuration Example
- Usage
- Troubleshooting
- Contributing
- License
- Dart version 2.16.1 or later.
Install LAND globally on your system to use it from anywhere:
dart pub global activate land
Ensure the Dart SDK/bin is included in your PATH. If not, you will need to add it. The method varies depending on your operating system.
On Linux or macOS, add it to your shell profile (e.g., ~/.bashrc
, ~/.bash_profile
, or ~/.zshrc
). On Windows, add it via the System Properties.
LAND can be used as an alternative to flutter gen-l10n
. Here are the steps to follow:
- Update your localization configuration file to specify only the output folder, not the output localization file.
- Rename your configuration file from
l10n.yaml
toland.yaml
. - Remove the
generate: true
flag from yourpubspec.yaml
file. - Add
/lib/.gen/
to your.gitignore
file to ignore the generated files. - Install LAND globally using the installation instructions above.
- Run
land
to generate the localization files.
After these steps, you should have a robust localization system set up for your Dart application.
One of the standout features of LAND is its support for multi-project localization. If you run LAND in a directory that isn't a Dart or Flutter project, it automatically searches for Dart or Flutter projects one level down from the current directory. This means you can generate localization files for all projects within a directory by running a single land
command. This functionality is especially beneficial in monorepo setups or when managing multiple related projects.
To use this feature, simply navigate to the parent directory of your projects and run:
land
Or specify the parent directory using the --path
argument like:
land --path <parent-directory>
LAND takes care of the rest, generating localization files for each Dart or Flutter project in the directory.
Create a configuration file named land.yaml
and place it in the root directory of your project:
arb-dir: l10n
template-arb-file: l10n_en.arb
output-directory: lib/.gen/l10n/
output-class: L10N
Create a folder named l10n
in the root directory of your application (outside lib
), and add your language files there. Here are a couple of examples:
{
"helloWorld": "Hello World!",
"@helloWorld": {}
}
{
"helloWorld": "Olá mundo!"
}
After running land
, all the localization files will be generated and ready for use.
If you encounter any issues while using LAND, please open an issue on our GitHub repository.
We welcome contributions! If you'd like to contribute, feel free to open a pull request.
This project is licensed under the BSD-3-Clause License.
Thanks for using LAND!