Using "lists of lists of lists" is no viable option. I tried this with my app (which needs 40 different language strings) and it turned out to be pure horror
Your entire code will look like this (method "getString" checks for current language and returns a text from the corresponding language text list):
So you'll have a hard time to look up what texts are actually displayed. Code gets absolutely cryptic and difficult to read. Additionally, lists are not visually numbered in the editor so to find out the index number of any text string requires you to manually count all items in the list over and over and remember the index number of the string you need to use. No way!
There must be a better solution for this.
Using dictionaries would be more comfortable but it seems that you can't create nested dictioniaries in MIT which would be required for a viable solution:
What we need would be an easy look-up method like this (pseudo code):
dictionary appTexts =
{
en =
{
YES = "Yes",
NO = "No",
CANCEL = "Cancel",
},
de =
{
YES = "Ja",
NO = "Nein",
CANCEL = "Abbrechen",
},
}
I suggest you to try dictionaries, they are similar to lists but you select items using text string called key. It makes everything a bit easier to handle.
Here's something i've done for my project, see if this is helpful!
1st create a list of buttons you have (here btn list)
2nd create a list of lists with their translations
As for labels, it becomes a little tricky(at least for me!) because i use same labels for different purposes at different times, like for eg. label1 will be used for "hello" , "bye" and so on.
So i've handled them like shown in the blocks below the local variable , i.e. as when it is required !
(Having everything in one screen w/ multiple virtual screens does help a lot ! )
(adding comments to both lists will help in reminding u to make necessary changes as you add more!)
Can you explain more about the structure of your app? From what i see, your 1st screen is only for setting the language and then you have subsequent pages with some info.
If this is the cases, you may want to consider using just one screen. If you still want to use a separate screen for setting up language alone, you should use open another screen with start value in the 1st screen and get start value in the 2nd screen (both of them are found under control in Blocks) . The 'start value' should be the language selected. You should also use TinyDB to store your choice, so that the choice is remembered for later use as well. Your getText function is wrong, the 1st element in the list should be either 'es' or 'fr' or 'en' . use the variable that has this info.
Also take a look at the if block in french.click and see if the logic checks out!
I am attaching pictures of the design for my first two screens of the app. I am trying to get the first screen to store the selection of the language on it and translate the content of the second screen to that language. I seem to be missing something.
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.
To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.
Here are the blocks and build design.
This is what I am using for the first screen. I am trying to understand how I get my second screen to be converted as well as the remaining screens in the app.
Hi!
I hope someone can help me with a "technical" doubt concerning this topic.
I'm developing an app in which the user can select different languages in a settings section.
For now, I started using the method that MauMau explained here to specify the text for each language:
But I also found on other post the idea of previosly making a file which already has the text for each language in lists pretty similar to the method with dictionaries.
So, my doubt is, in terms of app and memory optimization which of the two methods could be better?
Dictionaries are easy to use but take up a lot of memory in terms of RAM. I think it's better to have a file. It will takes some ROM but it will reduce memory issues, crashes and stuff like that.
Yes. You need a List of words for each language your app will know if you follow the example using lists. You can do something similar using Dictionaries (see How do I create multiple language app? - #14 by MauMau ).