Android Tutorial [B4X] Localizator - Localize your B4X applications

Localizator is a cross platform solution for strings localization.

The strings are defined in an Excel workbook.


They are then converted to a SQLite database file with a B4J program:


The database file should be added to the Files tab of your application.

Localizator is a class. You need to add it to your B4A, B4i or B4J program. It loads the set of strings based on the device locale or based on the forced locale (Localizator.ForceLocale).
Each string is identified by a key. The key matching is case insensitive. If there is no match then the key itself is returned (the value passed to Localize method).

There are some helper methods to automate the tasks. The main one is LocalizeLayout. It will go over all the views and will replace the matched keys.

Values can include parameters. For example "Hello {1}!". LocalizeParams deals with such values:
lblHello.Text = loc.LocalizeParams("Hello {1}!", Array(edtName.Text))
{1} will be replaced with the first parameter from the array.


- In B4A it is recommended to declare and initialize the Localizator from the starter service.
- The three examples attached are a bit more complicated as they allow the user to change the language.
In its simplest form you just need to initialize the localizator and call loc.LocalizeLayout.
- Languages two letters codes:


The compiled executable jar of the B4J converter can be downloaded from:
The source code is attached (depends on XLUtils).

B4A, B4i and B4J examples are also attached.

Localizator v1.01 is attached.

Automating the localizator:

B4XPages example:


    5.7 KB · Views: 1,450
    7.1 KB · Views: 1,863
    6.1 KB · Views: 1,142
  • Localizator.bas
    4.4 KB · Views: 1,856
    11.6 KB · Views: 1,395
    10 KB · Views: 624
Last edited:


B4X founder
Staff member
Licensed User
Longtime User
Automating the localizator

1. Add the xlsx file to the Files folder. This allows us to open the workbook directly from the IDE:


2. Updated command that works with Java 8+:
#CustomBuildAction: folders ready, C:\Users\H\Downloads\B4XLocalizator.jar, ..\Files\strings.xlsx ..\Files\strings.db
Last edited:


Active Member
Licensed User
Longtime User
Hi! Is there a way to indicate a default key if the current locale is not defined? Or should I use the key names as default locale?

Thank you very much for sharing this!


Active Member
Licensed User
Longtime User
Hy Luca, Thank you for your answer.

I've read that, but as I have my keys already defined I'd like to find the other way.

I've looking at the class code then, and I've found that "us" being the default locale when the current locale is not defined is already done:

Locale = FindLocale
    If sql.ExecQuerySingleResult2("SELECT count(*) FROM data WHERE lang = ?", Array As String(Locale)) = 0 Then
        Log($"Locale not found: ${Locale}. Switching to 'en'."$)
        Locale = "en"
    End If
    Log($"Device locale: ${Locale}"$)



Licensed User
I would like to use it.
Could you give a reference?

Is it this one, that you would recommend?
View attachment 53254

Un-be-lie-va-ble. This is a huge timesaver.

I am a bit late to this party, but: I agree, this technique is brilliant. A project I worked on few years back, we used the GOOGLETRANSLATE function directly, and had three columns for each language:

eg, if column A is key, column B is original language, then for columns C,D,E for the first translated language:

- the first column was the translation eg =GOOGLETRANSLATE($B3,$B$1,C$1)
- the second column translated it back to the original language eg =GOOGLETRANSLATE(C3,C$1,$B$1)
- the third column was either the translation, if it was unchanged after being translated back to the original language, or blank
eg =IF(D3=$B3,C3,"")

and then for each language we'd sort by the last column and print the original and three translation columns for all the mangled items, and give it to the relevant language speaker (eg, my dad for German, my ex-wife for French, the Chinese lady at the lunch shop for Mandarin...) to check.

Then we'd enter the corrected translations into the language last column, and pull the required columns into another page and save that page for "compilation" for use by the program's localization routine.

I have a vague recollection of a routine called Translate012(PhraseKey, Quantity) that would find the required translation using PhraseKey, and then use that line or one of the next two, depending on the Quantity, so that you'd have messages like:

Translation file:
Line 35: "VehiclesAvailable", "No vehicle found"
Line 36: "", "One vehicle found"
Line 37: "", "$Q$ vehicles found"

Program output:
Translate012(VehiclesAvailable, 0) = "No vehicle found"
Translate012(VehiclesAvailable, 1) = "One vehicle found"
Translate012(VehiclesAvailable, 17) = "17 vehicles found"

and the three messages could be wildly different, eg:

Translation file:
Line 35: "VehiclesAvailable", "NO vehicle is available :-("
Line 36: "", Just one vehicle left, so be quick!!!"
Line 37: "", "Multiple vehicles are available (would you believe $Q$?)"

and some other variations of Translate routines that would substitute strings in at placemarkers, so that, for example, adjectives could go before nouns in English ("the $C$ car" = "the red car") and after nouns in French ("la voiture $C$" = "la voiture rouge"). The Chinese lady would um and ah a lot, but our Chinese customers were rapt, one went so far as to say it was easier to read and use than "real" Chinese software (at least, we think that's what he said ;-)


Active Member
Licensed User
i just noticed the view texts with csbuilder value are converted to plain string. Is there a way to localize them too?


Active Member
Licensed User
Longtime User
When I want to start the B4Xlocalizator, it is missing libraries. Where can I get these?

Last edited: