B4A Library lmTranslation

The most useful way to use this library is to use it along with lmTranslationDBManager app.


[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 post #10]


Each language you add to your app could do double (probably ten times) the downloads of your apps.

This library allows you to easily and quickly add translations to your apps.
You could also use it along with lmTranslationDBManager, making your work even easier.


How you should work with this library (very easy):

"Inizialize" the library with the languages code you want your app "speaks".
B4X:
Dim lstLanguages As List : lstLanguages.Initialize
lstLanguages.Add("en") ' <--- developing languages
lstLanguages.Add("it") ' <--- first translation language
lstLanguages.Add("fr") ' <--- second translation language
'...
Translation.Init(File.DirDefaultExternal, "Translation.db", lstLanguages, True)

You can add other languages later, of course.
Add first the language that you use to develop. Above I set "en" - English, then I will use English to write my texts in my app, but I could choose any other language.

Then, simpy write your texts this way:
instead of
B4X:
bntOpen.Text = "Open"
MsgBox("Please, enter your name", "Log in")

you should simply write:
B4X:
bntOpen.Text = Translation.Tr("Open")
MsgBox(Translation.Tr("Please, enter your name", "Log in"))

At runtime, the library will search those texts in the db it created and it will replace them with their translations in the current language set on the device.
If lmTranslation does not find the translation, it would use the developing language (English, in this example).

So, you will have a db table similar to the above:
B4X:
'en                                      it                         fr
' Open
' Please, enter your name
' Log in

Now, you should add the italian and french translations:
B4X:
'en                                      it                                            fr
'Open                                    Apri                                          Ouvrez
'Please, enter your name                 Per favore, immetti il tuo nome               S'il vous plaît, entrez votre nom
'Log in                                  Accedi                                        Connectez-vous (I'm not so sure  ^_^)


You could do it manually, using some tool like SQLite Personal 3, for example.
But, MORE EASILY, you could use lmTranslationDBManager, an app expressly created to manage this database, which allows you to use Google Translate to translate your texts quickly and easily.
Take a look at lmTranslationDBManager.

App (lmTranslationDBManger) and library (lmTranslation) are not free (they can seem simple to develop but, as alway, the work was greater than expected).

You can donate (for both) an amount between 10 and 20 Euros, depending on how much you think you are generous (or depending on how much rich you are :D).

[EDIT: The price (lib+app) is now 15 € (or 6€ - 9€)]

If you want the library only... divide the amount in half :)

To receive these softwares, you can contact me at [email protected]
 
Last edited:

susu

Well-Known Member
Licensed User
Longtime User
Interesting! Do you have sample app?
 

LucaMs

Expert
Licensed User
Longtime User
Interesting! Do you have sample app?

Do you mean a source code project or an executable?

I suppose a source code project (what would you do with an apk?) but I'd rather get a small contribution from our generous :) colleagues, then I would prefer not to publish the library.

The example in the video should be enough to understand the operation.

The library has a few public methods, more than enough, as you can see in the video:

Init - Parameters:
..... DBPath - folder in which the db used for translation will be installed;
..... DBName - ^
..... Languages - all languages you want to provide;
..... CreateIfNotExists - create the db if it does not exists.
Tr - performs the translation (displaying the text in the current device language or in the developing language, if the first one is not available);
SetCurrentLanguage (and Get) - to test your app without the need to change the device language;
AddLanguage - to add a new translation language to db.

At runtime, if the library does not find the developing language text, it adds a new record for the text (and empty translations, of course, which you should then add - using lmTranslationDBManager you can do it quickly).

If "you" have other ideas, your suggestions will be always welcome.


[English' deficiencies :D: I need to add quotes to "you", because I mean "you all" and you could understand "you, @susu".
In italian, "you all" is "voi", "you only, @susu" , is "tu" :)]
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Done.

Now you should use something like:
B4X:
Translation.Tr2(Activity, True)

or
B4X:
Translation.Tr2(MyPanel, True)

upload_2015-9-26_9-9-14.png


(I hope the description is... in good English :D)


There's only one problem: now I will have to remake the video :D


Thank you again, @maxware
 
Last edited:

susu

Well-Known Member
Licensed User
Longtime User
I mean apk file that I can test on my phone.
 

LucaMs

Expert
Licensed User
Longtime User
As always, new features need tests.

Tr2 works but it has a problem:

if you run your app, then you add translations to the db created by the library (using some tool or my lmTranslationDBManager) all it's ok.

If your layout contains a Button1.Text = "Hello" (your developing language is English, for example) and you set Italian translation for it to "Ciao",
next time you run your app, Tr2 finds "Ciao" for Button1.Text and inserts "Ciao" as non-found English text!

This problem is with Tr2 only, of course, Tr works well.


I have to study a method to save something like: "Button1 already inserted" (I can not use the tag of the button, since the user may want to use it).

Anyway, just for test, I'm attaching the apk.

Some text in the attached project was added by Tr2, other by Tr (to test better the library).



But don't worry, I will solve this problem ("don't worry"? It seems that this library does not interest anyone, or almost. Tasteless people :D).


[SOLVED: see below]
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
[SOLVED: - you can test WithPanelTest.apk attached]

This example (WithPanelTest) is ready for English (developing language), Italian, Spanish (I could add more languages, if I would, of course)


Given the very small number of requests, the price (lib+app) is now 15 € (it was 10€ before) :p
 

Attachments

  • WithPanelTest.apk
    136.9 KB · Views: 204
Last edited:

LucaMs

Expert
Licensed User
Longtime User
More easy and quick now, with Translation.Tr2(Activity, True) (or Translation.Tr2(YourPanel, True))
It translates texts you added by Designer (you don't need to write code line like: Button1.Text = Translation.Tr("Close")
But you can still translate all texts in your app using Translation.Tr, not only views' texts))

 
Last edited:

susu

Well-Known Member
Licensed User
Longtime User
[SOLVED: - you can test WithPanelTest.apk attached]

This example (WithPanelTest) is ready for English (developing language), Italian, Spanish (I could add more languages, if I would, of course)


Given the very small number of requests, the price (lib+app) is now 15 € (it was 10€ before)

I installed your app then changed language of my phone to Italian but the text still in English. I tried again with Spanish but nothing change.
My phone LG G Pro with Android 4.1.2.
 

susu

Well-Known Member
Licensed User
Longtime User
As I told you in other thread. You confused me (again) with non-working sample app. Before you sell something you need to test it first, right?
 

MaFu

Well-Known Member
Licensed User
Longtime User
Maybe because solutions for multi language apps already exist for free?
Your Lib should have a clear added value over the existing solutions.

And the price for a product that does not sell well usually falls and does not rise.
 

LucaMs

Expert
Licensed User
Longtime User
Maybe because solutions for multi language apps already exist for free?
Maybe... but i don't know another so easy to use solution and, moreover, other solutions which uses translators, like Google Translator.
In fact, I had to create this for myself.

And the price for a product that does not sell well usually falls and does not rise.
I know; for this reason I have written:
"Since I am a great strategist in trade matters and because the demands are very poor, I have raised the price from 10€ to 15€ :p" (but only here).
It is a provocation; I did not expect to earn this way, my priority was to develop this for myself and I'm sure these tools will help me much.

To better explain the price increase I added this motivation, now: ":p"
 
Last edited:

Derek Johnson

Active Member
Licensed User
Longtime User
[QUOTE="
"Since I am a great strategist in trade matters and because the demands are very poor, I have raised the price from 10€ to 15€ :p" (but only here).
It is a provocation; I did not expect to earn this way, my priority was to develop this for myself and I'm sure these tools will help me much.

To better explain the price increase I added this motivation, now: ":p"[/QUOTE]

I can see the rational, it is like this:

[Attempt at joke:]

"The floggings will continue until morale improves"

[End of attempt at joke]

(This may not translate very well!)
 
Top