I have a full-fledged working Flutter app. Now, I want it to support multiple languages, such as Spanish, Hindi, Urdu, etc. (primarily Indian Languages which are available in Google Translate).
I have searched about this, but all of them mention about "arb files" in which I believe, I have to manually write each and every translated string of the whole app.
I would like to build a package with a class (or just a method) which may require 2 parameters, string and the locale in which translation is required.
Kindly suggest me the best way to achieve it and how can I do it. A link to tutorial would be appreciated.
Flutters own step by step walkthrough to i18n is literally the first result that pops up when you put "Flutter localization" into Google.
https://docs.flutter.dev/development/accessibility-and-localization/internationalization
If for some reason you don't want .arb files, you can roll your own. But be prepared that you will find out along the way what is missing and ending up with a home-brewn solution that is worse than Flutters own to achieve the same thing.
There is no magic function to translate text. Even if you could translate on the fly with a translation service, translation services have become really good in recent years, but they (as any human you could hire) are only as good as the context they get. If they get only single words or half sentences, as is common in an app with headlines and buttons, the result will be horrible. As if you just put every single word into a dictionary. That is not translation. It will feel artificial and laughable.
So... give the existing packages a try. Start with Flutters. It might seem complicated, but it's complicated for a reason.
Related
Why do some Android projects list a "CHAR_LIMIT" in comments above each string in strings.xml? For example, from https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/strings.xml:
<!-- [CHAR LIMIT=25] String for confirmation button to enable a feature gated by the battery saver warning-->
<string name="confirm_battery_saver">OK</string>
<!-- [CHAR_LIMIT=NONE] Battery saver: Feature description, with a "learn more" link. -->
<string name="battery_saver_description_with_learn_more">To extend battery life, Battery Saver:\n·Turns on Dark theme\n·Turns off or restricts background activity, some visual effects, and other features like \u201cHey Google\u201d\n\n<annotation id="url">Learn more</annotation></string>
Googling turns up a few other examples, but no explanation. I don't believe Android documentation covers this. And unlike tags like <xliff:g> it doesn't seem to be an official, functional component of Android. My best guess is that it's a convention some projects use to indicate "when you translate this, make sure the translated version doesn't have more than X characters or else it will break the UI!" Or perhaps, vice versa, "if you're using this String, make sure the UI still looks good with a String X characters long"
My thought is that the UI should always be built to be as flexible as is reasonable, given the possibility for translations of different lengths, and the possibility of different text sizes. Also that translators should strive for the translation to be more or less the same size as the original text, instead of going from, say, 10 characters to 50 characters when translating. So I would think this "CHAR_LIMIT" would be completely unnecessary and could be dropped. (I ask, because I'm touching up an old open source project that uses this.)
Is my understanding of "CHAR_LIMIT" correct, or what is it for, and should it be used?
when you translate this, make sure the translated version doesn't have more than X characters or else it will break the UI!" Or perhaps, vice versa, "if you're using this String, make sure the UI still looks good with a String X characters long
That's pretty much my understanding of it.
I searched around a bit for where this clue is used, and I found only a single place: stringslint.py. This is a lint script that seems to be used on strings.xml files. Maybe the project you're talking about used this script? The file docs say:
Enforces common Android string best-practices. It ignores lint
messages from a previous strings file, if provided.
Usage: stringslint.py strings.xml
Usage: stringslint.py strings.xml old_strings.xml
In general:
Errors signal issues that must be fixed before submitting, and are only used when there are no false-positives.
Warnings signal issues that might need to be fixed, but need manual inspection due to risk of false-positives.
Info signal issues that should be fixed to match best-practices, such as providing comments to aid translation.
So that goes along what you were saying. It's a clue for translators but can also be used for lint checks, hence the easily parseable syntax.
I also tried to search for pages explaining how one would translate the Android System, hoping CHAR LIMIT would be mentioned somewhere. But it doesn't seem like the community can contribute their own translation, so I found no such page.
Note that there's also a BACKUP_MESSAGE_ID that's declared in the same way for some string resources. It seems related to the system Settings app, but I don't know any more that than.
EDIT: I found another script using it: https://chromium.googlesource.com/chromium/src/+/master/tools/grit/grit/tool/android2grd.py, although this time it's CHAR-LIMIT.
If I wanted to translate an entire app (with button names and labels, and long text), is it better to just make a different app? Or is there a translation api I can use?
The reason I ask is that I tried going to the Goolge Play store and searching it in a different language, and it basically didn't understand what I wanted. So is there a different Goolge Play interface for different languages? Or some setting which I need to turn on?
How does this generally work?
Thank you!
use all your strings from a file instead of hard coded way. the name of the file is strings.xml in values folder, and for another language what u need to do is to crate values-ru values-ch etc. folder and put your strings.xml inside the folder. and change the values. this was a fast approach to explain your solution. for expanded, detailed solution is here : http://developer.android.com/guide/topics/resources/localization.html
You don't want to make multiple versions of the application. In general this is accomplished by using a locale-specific dictionary for each translation you want to use, so instead of hard-coding strings in your application you would reference an element in the appropriate reference database instead, which is basically a list of all the strings you use in your application.
Here's some information I found specifically for Android development: http://developer.android.com/guide/topics/resources/localization.html
As for translating, natural language processing isn't far enough along yet to give good translations automatically, especially without context. You can try Google's translate API (https://developers.google.com/translate/) which uses some statistical methods, but even that will likely give you erroneous translations (I'm sure you've probably used Google or another service to translate something and out came something you could be pretty certain wasn't accurate). You might be able to use that as a first step to converting the application to different languages and, if your application is open source (or even if it isn't) ask for user input as to the accuracy of the various translations.
Hopefully that is helpful.
My android app has a drop down List,From where user can change language like English, Javanese so on. when user change language then app language will be change. It is a simple app where has only one layout.Please any one help me
I wouldn't trust on-the-fly translation of your strings; even the best automatic translators can produce inaccurate output. Additionally, you add a fair amount of complexity, overhead, and dependency (e.g., having a network connection) by handling translation this way.
The problem of having a "multilangauge app" (as you called it) is well-known, and the process of solving it is called internationalization and localization . In general, when you're working with a framework or programming language, you can look for existing packages/libraries relating to this topic -- it's almost a given that others have spent significant time building a good mechanism(s) to facilitate this.
Android is no exception; it's been developed with localization support built-in. The Android Developer Documentation has a comprehensive guideon Localization that you should take a look at. You'll still need to translate your text somehow, but a lot of the "groundwork" of how you can serve up locale-specific messages to the user has already been laid out for you.
One last note -- the Android docs also provide a tutorial called " Hello, L10n", which walks you through the basics of creating a localized app. Hope this helps!
so I am starting to learn how to develop Android Applications. I have experience with Java and C# from school, and I would say that while I am not a pro, I definitely have a fairly good handle on Object Oriented Programming.
So one thing I don't understand about Android is resources. For example, let's say I have a TextView in my GUI. Why do I have to define a string "Hello," then make the value that string called "Hello" = "hello?" I don't understand why the software development kit doesn't just let users make that string value "hello," and be done with it. What is the purpose of storing numbers and strings and stuff into resources? I know that there must be a solid explanation for this, but I just don't know what.
Also, I am experimenting with an Addition program (where I prompt the user with a randomized math problem, and they can input their answer, and my program will check if it is right or wrong, and restart). So I have a TextView for the problem (i.e., 1 + 1). When I create the TextView, I had to create a problemString in the resources, and then assign the problem TextView to the problemString. However, in my program, when the user has gotten the math problem right or wrong, I write over the problem with a new problem by simply changing the text of the textview. In no way do I interact with the problemString from the resources. And this works. So again, my question is, what is the purpose of having application resources and what role do they play in an application.
Also, how do I access, write over, and do stuff with the application resources.
Sorry that this is a really long question, but I really think Android dev. is really cool, and I am very eager to learn. Any help is APPRECIATED! xD
Thanks!
Imagine your application with a thousand different strings to display to a user. If you need to change 30 of them, do you want to dig through all your code, or one file?
Also localization is another reason for having different sets of string resources, as well as other resources, specific to a locale. Take the above scenario, a thousand different strings, AND three different languages. How would you handle that? Three different version programs? No.
I would like to create a custom open source information management application, that I could adapt to practical needs of a psychiatrist. (and also would really like to avoid inventing the wheel). Could someone advise me what would be a good way to start? I have some amateur programming experience (see below), but I have little experience with java and eclipse (which I have set up with Android SDK plugin on my linux PC).
What I would like to achieve is a simple app where I could relatively easily re-program/rearrange information presenting screens. I would like the major development stages to be something like:
Basic framework of the app is done Main information is added
through the programming environment
basic formatting (bold, color, lists) should be supported
I imagine this would be through HTML/CSS markup Hierarchical (not
too deep) screens with concise information about conditions,
treatments; easy, not too cumbersome navigation is a must.
Possibility to attach own notes from android device
on every piece of information (e.g. on medical condition, on medication,
list of differential diagnoses, etc)
A desktop application that allows for easy adding and editing
of the content
initially could be even sqlite manager or something similar
possibility for adding images,
possibility to add rating scales, which would calculate scores
maybe also possibility to print through some android print driver
* in essence I envision this as a sort of an integrated website with a relatively simple database behind it (sqlite?) running on android. My models would be epocrates and medscape apps, but the content would be more specific to everyday psychiatric practice. It would include aspects of psychological therapies as well.
In about a years time, I think, the content would be interesting enough to see whether the app should go on the market.
My (limited) experience:
I am a MD - a Psychiatrist. I have some amateur development experience (php, html, css, Perl, bash, sed, sql, Access and some time ago - AS/400). I would like to start an app that I could modify as I go - in order to have the most useful info at my fingertips, when I need it in my work. I have considered some databases (e.g. HandDB) but my experience with them is that you get very constricted with their user interface and this hinders fast information retrieval when you need it. Adding information can be clumsy as well.
Why I am asking for help here
Most of tasks above seem pretty standard. I imagine that people with lots of programming experience here, probably would be able to point me towards some information that would help me to get started.
Many thanks for considering this :)
Are you going to develop this app? Everything you mentioned can be easily done by reading the android documentation. Although if its you doing the coding i recommend buying a book
You will find a lot of samples and other support in the android doc
Printing can be also setup using Google Cloud print
If you want to open source your application you can always use google code.
You have asked a really broad question here. But i guess the above information is good to get you started.