What is the structure of a property file and how to localize this type of file? Separating User Interface strings from the source code of an application is important to smoothly localize software. UI strings are fields name: first name, last name, email and warning messages: invalid email or required field. Java programming language stores these strings in Properties Resource Bundles.
- File extension: *.properties
- Every single line has one segment in the format of a Key/ Value pair.
- The Key/ Value pairs may have several formats like key: value, key = value, key = “Value”, key=’value’.
- The right side of the key pair is the string that needs to be translated.
- Use # or ! to add a comment.
- The file can be opened and edited in any text document: Word, Notepad, Notepad++.
How to localize it?
Well, I will share different ways of preliminary localization engineering because not all of us use the same CAT tools or workflows. As we all know a property file cannot be sent as-is for translation because of the following:
- The Analysis will be inaccurate because it will include non-relevant content like:
- Comments (# text)
- the Key on the left side of each line of text.
- The file will be corrupted if the key is translated. Remember, the key in a property file should remain as is.
- Direct Translation is a bad practice because there will not be a bilingual file to clean over a Translation Memory.
Prepare the file using an MS Word document and Macros or Wildcard:
- Open the properties file using any text editor and copy the content into an MS Word document.
- Open Find and Replace (Ctrl + H)
- Put the cursor in Find what then check Use wildcards
- Insert ([!^13]@=) in the Find what. (Explanation below)
- The ^13 = Paragraph mark.
- ! = NOT
- […]@ = Do the same action for any repetition of characters that match the expression in the brackets.
Note: Remember to replace the “=” if the property file use “:“.
- in Replace with, if you have Trados styles then use Tw4winExternal. If you are using another tool, so you can hide the left side text and the CAT tool then will not count it:
- Put the cursor inside Replace with
- Select Font from the Format options
- Check Hidden
Remember during the Final Engineering phase, you will have to convert the file back to (*.properties). To do so follow the next steps:
- Clean the bilingual file using your CAT tool
- Open the MS Word document and save it as *txt. You MUST convert the encoding from ANSI to UTF-8 or the final file will be corrupted.
- Save as the txt file as *.properties.
Prepare the file using SDL Studio 2019
Using Trados Studio, the process is a lot easier. Once you create a new package, set up the source and target language(s) and add the files, Trados Studio automatically will detect that this is a Java Properties files:
Also, Trados Studio will protect automatically all the left side of the “=” as well as any comments in the document and will only keep the right side that needs to be translated.
In case there is custom content that is not relevant for translation, you can adjust the Java Resources file type from the project settings. Here you can adjust or add new regular expressions.
To conclude, Trados Studio makes it very easy to prepare these types of files. The first mentioned approach is valid for those who are not using Trados. This approach can as well be used to protect any type of files using Key/ Value pair other than *.properties
Feel free to leave a comment or Contact Me for an open discussion!