Package: i18ntools
i18ntoolsTranslate i18n Java properties files to desired language(s).Description•Installation•Usage•LicenseDescriptioni18ntools is a collection of Python scripts to help translate your Java properties internationalization files
usingAzure Cognitive Services Translator.What does each script do?translate.pytranslates an entire i18n Java properties file into a new i18n Java properties file of a different language.translate_missing.pytranslates the messages in an i18n Java properties file that are missing
from an i18n Java properties file of a different language.
The missing messages will be appended at the end of the output file unless the--sortoption is used.
Note: using the--sortoption will delete comments in the output file that are not present in the input file.parse_i18n_file.pyreads an i18n Java properties file and returns the data as a dictionary.sort_i18n_file.pysorts the messages in a given i18n Java properties file so that they are
in the same order as the messages in a different i18n Java properties file.
Using this script will delete comments in the sorted output file that are not present in the input file.InstallationYou can currently only clone this repository to run the scripts:gitclonegit@github.com:hypercision/i18ntools.gitNavigate to the cloned repository and create avirtual environmentto run these Python scripts on your local machine:cdi18ntools
python-mvenvi18n_envsourcei18n_env/bin/activateThe command to activate the virtual environment on Windows is:i18n_env\Scripts\activate.batThen install the packages required by our scripts and an editable installation of this package:pipinstall-rrequirements.txt
pipinstall--editable.When this package is installed, CLI executables of the scripts will be installed on the path of your virtual environment.translate--help
translate-missing--help
parse-i18n-file--help
sort-i18n-file--helpPython “Virtual Environments” allow Python packages to be installed in an isolated location
for a particular application, rather than being installed globally.
You should run all your Python commands with your virtual environment activated.
Once you are done using Python, you can exit the virtual environment by enteringdeactivatein your terminal.UsageBefore usingtranslate.pyortranslate_missing.py, your Azure API secret key must be set in
an environment variable namedTRANSLATOR_API_SUBSCRIPTION_KEY.exportTRANSLATOR_API_SUBSCRIPTION_KEY=<your_key>You can accomplish this on Windows with the following command:C:\>set TRANSLATOR_API_SUBSCRIPTION_KEY=<your_key>Suppose you have the following in a file named/home/docs/example.properties:default.invalid.min.message=Property [{0}] of class [{1}] with value [{2}] is less than minimum value [{3}]# Track 4 on Expert In A Dying FieldTheBeths.YourSide.lyrics=I want to see you knocking at the door.\I wanna leave you out there waiting in the downpour.\Singing that you’re sorry, dripping on the hall floor.instructor.submitWithCustomTime.customSubmitTS.missing.error=The customSubmitTS parameter is missing.\It must be present and of type Date.# SessionItem.itemID is the first parameterinstructorService.removeSession.success={0} session removed.handshake.register.suspended.error=The trial period has ended for your account\and you can no longer use the application.handshake.register.disabledException.error=Instructor is disabledWhen you run:translate-i=/home/docs/example.properties-t=es# Or you could call the file directlypythonsrc/i18ntools/translate.py-i=/home/docs/example.properties-t=esThen a new file named/home/docs/example_es.propertieswill be saved and contain Spanish translations
of the input file, with the comments preserved:default.invalid.min.message=La propiedad [{0}] de la clase [{1}] con valor [{2}] es menor que el valor mínimo [{3}]# Track 4 on Expert In A Dying FieldTheBeths.YourSide.lyrics=Quiero verte llamando a la puerta.\Quiero dejarte ahí afuera esperando bajo el aguacero.\Cantando que lo sientes, goteando en el piso del pasillo.instructor.submitWithCustomTime.customSubmitTS.missing.error=Falta el parámetro customSubmitTS.\Debe estar presente y ser de tipo Fecha.# SessionItem.itemID is the first parameterinstructorService.removeSession.success={0} sesión eliminada.handshake.register.suspended.error=El período de prueba ha finalizado para su cuenta\y ya no puede usar la aplicación.handshake.register.disabledException.error=El instructor está deshabilitadoOptionsThese are the options fortranslate.py.
Details about how to use each file can be found by running it with the--helpflag:python src/i18ntools/translate_missing.py --help.KeyAliasDescriptionDefault--help-hAll available options./--region-rRegion of the Azure translator resource.eastus2--input_file [required]-iPath to a.propertiesfile to translate./--from_lang-fFrom which language you want to translate.en--to [required]-tTo which language you want to translate. For example, use de to translate to German./--output_file-oPath where the translated.propertiesfile will be saved. Overwrites any existing file.input_file with the output language appended to the filename; i.e.,messages.propertieswould becomemessages_de.properties.Obtaining API keysAzureFollow the instructionshere.LicenseMIT