App localization - languages.

LucaMs

Expert
Licensed User
Longtime User
[EDIT: Very important addition, thanks to @maxware's suggestion: added method Tr2, which will translate all texts in an Activity or Panel, so you don't need to write many lines of code and, ALSO, you can add translations to your old projects.
Just one code line: Translation.Tr2(Activity, True)]
See #23

A pair of "things", a library and an app to facilitate apps localization, using Google Translate.

I will add audio or subtitles or other to the video.

But... where I should publish this work? "Share your creations"? "Additional libraries..."?

Well, for the moment I will appreciate your comments.


Thank you



[Speaking of languages ... I would have to write: "It's very easy ..." :D]


 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
It is not a good video, it is not a good example and also the use of Google Translate "happens" a few minutes later the start, it is better to do it before.

You could only use Google Translate to fill the EditTexts.

[AHLocale and SQL libraries are not needed, I forgot to remove them in the example]
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
IMPORTANT:
The developing language is your choice, it is not necessary to use English as the example.

I could develop in Italian:

btnApri.Text = Translation.Tr("Apri")

or in French:

btnOuvrez.Text = Translation.Tr("Ouvrez") (I suppose :D)
 
Last edited:

wonder

Expert
Licensed User
Longtime User
Interesting project... :)
So is the database something like a dictionary?
 

LucaMs

Expert
Licensed User
Longtime User
THANK YOU FOR YOUR ANSWER, @wonder :D.

There is a db for each app you create, which contains only one table, like:
B4X:
' en     it     es     ...
Today    Oggi   Hoy
...

Using the library, you can set the languages you want to use (you will able to add new languages after, of course, using the library or the app, which is a specific little DB manager).

Simply writing code like:

btnOpen.Text = Translation.Tr("Open") <--- if you set English as developing language, but you can choose any other language to develop.

and at run-time the library will replace that "Open" accordingly to the current device language. If the current language is not in the db, "Open" will be set.

The app is very useful, mostly because, when you should add translations texts, you just press Enter, Google Translate will open displaying the translation for the current EditText to modify and when you close Google Translate you will have the translation (I searched for services to obtain this behavior without the need to download a web page and use copy&paste, but I found few non-free services only).

The app has also other (minor) features, like importing CVS file containing translations and management of all typical operations on DBs, including adding/removing columns, sorting, selecting (displaying) only empty fields (translations)...

It is too hard to explain, very easy to use.

I made it for me, I need it, but I'm sure that, if you want to sell your app all over the world :) you need to add languages to it.



Thank you again for your (first? Or unique?:p) answer, @wonder
 
Last edited:

wonder

Expert
Licensed User
Longtime User
It's a really good idea, Luca!!

If I understood correctly, you have to add the translations to the DB with the companion app, right?
Why not add the app's capabilities to the library?

Something like this:
If the current language is not in the DB, the lib will "google translate" the developing language (ex: English) to the system language (ex: Italian) and store it on the DB.

By the way, no need to thank me for the replies. :)
 

LucaMs

Expert
Licensed User
Longtime User
It's a really good idea, Luca!!

If I understood correctly, you have to add the translations to the DB with the companion app, right?
Why not add the app's capabilities to the library?

Something like this:
If the current language is not in the DB, the lib will "google translate" the developing language (ex: English) to the system language (ex: Italian) and store it on the DB.

By the way, no need to thank me for the replies. :)

Because the library will be included in the app produced by developer, then if I did it the end user should enter the translations; also the app might not have the need for internet connection.

But thank you for your suggestion, @wonder
 

Beja

Expert
Licensed User
Longtime User
LucaMs......... said:
It is not a good video, it is not a good example and also the use of Google Translate "happens" a few minutes later the start, it is better to do it before.
.
I forgot to remove them in the example]

LucaMs,
You are a great marketing specialist.. I will send you my new product to sell them.
 

asales

Expert
Licensed User
Longtime User
But... where I should publish this work? "Share your creations"? "Additional libraries..."?
In both, I think. The library in "Additional libraries..." and an good and complete example (or an app yours using this library) in "Share your creations".

The translation in app is fast, even I have several strings in activity to translate?
 

cimperia

Active Member
Licensed User
Longtime User
Interesting Luca.

Here are a few light musings, that may be relevant or not:

Your implementation might create performance and scalability issues if the layout contains many texts that need translating.

I would probably modify the db structure so as to add, for example, a layout column (or more likely 2 extra tables to keep your database normalized).

You could then add an optional method in your class that would take a layout name as parameter and it would populate a map with the translations for the current layout.

So, regardless of the number of translations to be done, one single db call would be enough. Afterwards, reading from the map would be a very quick process.

This implementation would be a must if you wanted to port your solution from local to a back-end db across networks. The query itself would be slightly more complex and slow, but there is a threshold beyond which it’ll be faster.

Another very different approach would be to get your App ImTranslation to offer the option of generating static code to be copied and pasted into one’s own app. In effect there would be a global map variable pre-populated that would be used to translate the UI texts instead of making calls to the database, which would not need exist in the user app. It would be very fast but it’s strictly a local solution. The memory required is very likely to be very low, unless you have thousands of text to translate.

As I said, just a few thoughts that, luckily, you may perfectly ignore ;)
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
First, thanks for your suggestions, always welcome.

They make me realize that I forgot to specify something: the translations are not just layouts texts translations but also any text in the code, such as MsgBox, Toast, Log, etc.

If I understand what you mean, I could discriminate between different layouts (and also texts in the code), but you have to consider using a single table and a single key field I can use Translate.Tr("Hello") everywhere I need "Hello", without duplication.

lblTitle.Text = Translate.Tr("Hello")
MsgBox(Translate.Tr("Hello"), "")
...

same unique field.

Also, the user/programmer should take in account (write) which text is contained where. So, instead, it is very simple to use.



I did not understand the matter of the maps; I should fill the maps from the db and use them for translations? I do not think there are huge advantages in speed (probably a little bit yes, but you lose time initially to fill the maps).


However, I will do some tests, adding many texts at runtime and will let you know.
 

susu

Well-Known Member
Licensed User
Longtime User
Ok, when will we can get it? :D
 

LucaMs

Expert
Licensed User
Longtime User
Ehi, @cimperia, ho finalmente finito l'app e adesso mi apprestavo a pubblicarla e poi a rileggere bene il tuo post ma l'hai eliminato :(. Grazie, comunque.

@cimperia, I completed my app and now I'm going to publish it and then I would have gone to read better your post but you've deleted it. Thank you, anyway.
 
Top