In this guide, we use
mojito-cli to extract strings from source resource file. Translatable strings are extracted from source resource file and stored in the repository. This process is called
push in mojito because extracted strings are “pushed” to mojito.
For mojito supported source resource files, see Supported File Formats.
Let’s say we have the following source resource file
strings.properties in the current working directory.
# Greeting from Main UI hello = Hello! # Displayed in the Main UI when user logs out. bye = Goodbye. Have a nice day!
mojito push -r MyRepo
This extracts the two strings from the source resource file and stores them in
MyRepo repository. The two strings are now visible in mojito and ready to be translated in locales configured in the repository.
Overriding Source Directory
mojito push -r MyRepo -s relativePath/ProjectA mojito push -r MyRepo -s /home/explicitPath/ProjectA
By default, mojito searches source resource files from current working directory and its sub-directories. If you have your source resource file in a specific directory, you can use
-s parameter to telll mojito where to find source resource files. The above example extracts strings
ProjectA directory using relative path and explicit path.
Specific Source File Type
mojito push -r MyRepo -ft PROPERTIES
By default, mojito processes all supported source resource files in the working directory. If your working directory has many types of source resource files and if you want to only process specific type, you can use
-ft parameter. The above example only extracts strings from Java Properties file.
Available file types are
PO. The difference between
PROPERTIES_NOBASENAME is that the source resource file of
PROPERTIES_NOBASENAME has source locale name as the file name. For example,
Overriding Source Locale
mojito push -r MyRepo -sl en-US -ft PROPERTIES_NOBASENAME
en as source locale by default. mojito uses soure locale to identity source resource files from localized resource files. For example, if you have
en-US.properties in your working directory,
en.properties is used as source resource file by default and
en-US.properties is considered as localized resource file. The above example overrides the default source locale and use
en-US as source locale using
-sl parameter. You must use
-sl parameter with
Specific Source File Regex
Let’s say you have the following source resource files in working directory.
release-1.1.xliff release-1.2.xliff release-2.1.xliff
You can use regular expression to filter source resource files to push. The following example only processes release-1 related files using
-sr parameter for regular expression.
mojito push -r MyRepo -sr "^(release-1).*$"