A command-line tool to convert Android XML string resources to ARB (Application Resource Bundle) files.
dart run bin/android_string_convertor.dart [options] {files/directory}-p, --prefix <prefix>: Prefix for output file name (defaults to "app_")-s, --[no-]sort: Sort the output by key name-d, --[no-]directory: Input is a directory containing XML files-o, --output-dir <output-dir>: Output directory for ARB files (default is same as input directory)
Single file:
dart run bin/android_string_convertor.dart ./example/en.xmlMultiple files:
dart run bin/android_string_convertor.dart ./example/en.xml ./example/es.xmlDirectory:
dart run bin/android_string_convertor.dart -d ./exampleSort output by key:
dart run bin/android_string_convertor.dart -s -d ./exampleUse custom output prefix:
dart run bin/android_string_convertor.dart -p "test_" -d ./exampleSpecify output directory:
dart run bin/android_string_convertor.dart -d ./example -o ./outputThe tool reads Android XML string resource files and converts them to ARB (Application Resource Bundle) files, which are used for localization in Flutter applications.
The main steps are:
- Parse the input XML file(s) or directory using the
xmlpackage. - Extract the string resources and their keys from the XML document.
- Optionally sort the string resources by key.
- Write the string resources to an ARB file in the specified output directory (or the same directory as the input, if not specified).
- Dart SDK 2.19.0 or later
argsandxmlpackages
To use the Android String Converter tool, you can run it directly from the command line using the Dart runtime:
dart run bin/android_string_convertor.dart [options] {files/directory}Alternatively, you can build the tool as a standalone executable using the dart compile command:
dart compile exe bin/android_string_convertor.dart -o android_string_convertorThis will create an android_string_convertor executable that you can run directly without the dart run prefix.
If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on the GitHub repository.