Find untranslated resources at runtime - android

I want to find out how many string resources are not translated into the currently used app language.
I want to show my users some information like following:
Sorry that this app is not yet translated into your language. Do you want to help translating it? Translators get this app's pro version for free.
OR
n strings are not yet translated into your language. Do you want to help translating those strings?
Main goal
Encourage the users of already translated languages to help me translating new strings. Telling the user that only 10 or 20 strings need translations will encourage a lot more users to help me translating the app I think...
Additionally I can show a popup if the users wants to to inform him about new untranslated strings...
Question
how can I count all strings in the default language?
how can I count all strings in the current language (only the ones that are translated)?
At least this should be possible with a gradle script whoch generates some constants, did anybody ever do this? Any better ideas?

Related

How to limit the use of certain character sets

I hope this question isnt going to be down-flagged for not showing some actual code, but thats the core of this situation. I simply have no clue where to start to solve this issue, even after trying to use several combinations of keywords on both Google, and here on SO.
My client suddenly decided that half of the Android App I'm developing for him has to be Chinese, so after I have made some changes in the Database so some fields can take in Simplified Chinese character sets, I need to make sure that my client (living in holland) only uses those characters in that particular EditText field in the app. (There are more Database fields that now only allow Simplified Chinese, however these values come from a dropdown list in the app, so I dont need to worry about wrong characters for them).
So how would one make sure that only Simplified Chinese is used in an EditText field?
Here is a project in Ruby that attempts to detect whether characters are Traditional Chinese, Simplified Chinese, or Japanese (maybe others?): https://github.com/jpatokal/script_detector
This detection is based on the Unihan Database, in which there is a file called Unihan_Variants.txt. (Download zip file containing this text file here.)
Conceivably, you could parse the txt file into a lookup table and check the unicode value as the text is entered during onTextChanged() for your EditText. However, the readme on the project linked above states: "It is important to understand that this requires long sections of text to work reliably, since a single character or even several characters may be valid Japanese, traditional Chinese and simplified Chinese simultaneously." So, weeding out characters on an individual basis might prove difficult.

what is the best way to store and retrieve strings in vernacular(multiple languages) android apps?

I am working on vernacular(multiple language support) android app where I am giving option to the user to change language. So what is the Best way to store and retrieve strings, Weather to store strings in multiple strings files according locale (But it increases app size) or to get strings from server when user changes the language or any other? Let me know if you don't understand any thing.
I would recommend you to use the Locale and create a separate file for each language with the same keys but different values according to the language. For more details, pleae have a look : http://developer.android.com/training/basics/supporting-devices/languages.html

How To Detect Is Text Human Readable?

I am wondering if there's a way to tell a given text is human readable. By human readable, I mean: it has some meanings, format like an article written by somebody, or at least generated by a software translator that is intended to be read by a human.
Here's the background story: recently I am making an app that allows user to upload a short text to a database. At the early stage of deployment I noticed some user always uploaded corrupted text due to a problem with encoding. This problem is fixed later, but leaves me wonder if there's a way to pick up non human readable text before serving the text back to users.
Any advice will be appreciated. The scope might be too large to include other languages, so at the moment let's limit the discussion to English only.
You can try a language identification tool, or something similar.
Basically you have to count the characters, or groups of character (character n-grams), and compare the distribution of the letters of the text submitted with the distribution of the letters of a collection of texts written in good english. (Make sure that such collection of texts is representative of the expected input).
In the continuity of a N-gram approach you might want to try a dictionary based approach and check for the presence of 'stop words' (e.g. 'the', 'a', 'an', 'of') in the input text.
Most of the NLP-Libraries will do the job (Spacy is a very common one). You can also go for language detection: Langdetect will support you on this
(https://pypi.org/project/langdetect/) as many others will do. If you need to be less specific (more math than language) you should look for Phonotactics (with BLICK for Python: https://github.com/mmcauliffe/python-BLICK) that looks into the construction of character order in a string.
Do a hexdump and make sure each character is less than or equal to 0x7f.

ANDROID: What is the main idea behind of using strings.xml?

Someone please explain what is the main idea of using strings.xml?
I think it would be useful for multi-language support but how can we organise it for that?
Do I need it if I don't want to use multi-language support in my android application?
The idea is that it represents a single location for various strings, so your code isn't peppered with string literals. In addition to that, you gain the ability to easily localize. Organization of files for localization is covered here:
http://developer.android.com/guide/topics/resources/localization.html#creating-alternatives
Do you need it if you're not localizing? No. But it may make things easier in the long run, and I would recommend using it just for that reason.
Hard-coding strings is Bad.
Parameterizing strings (e.g. with strings.xml) is Good.
Being able to internationalize your strings (with language and/or locale-specific versions of strings.xml) is even Better :)
PS:
To make use of internationalization, just create resource subdirectories. Google will give you plenty of references/examples. Herre's one:
http://developer.android.com/guide/topics/resources/localization.html
* res/values/strings.xml
Contains English text for all the strings that the application
uses, including text for a string named title.
* res/values-fr/strings.xml
Contain French text for all the strings, including title.
* res/values-ja/strings.xml
Contain Japanese text for all the strings...
And yes, you should absolutely get in the habit of using strings.xml (and colors.xml and dimens.xml etc etc) even if you don't plan on internationalizing immediately.
IMHO....

Translating XML strings for Android

I have some customers who have volunteered to translate my app's strings into their native languages. Of course they will not be using the Eclipse Android environment to do this, so what Windows-based tool/editor would be appropriate for them to use to work on the XML files that I send them?
I've been following your strategy as well for quite some time. Whenever a volunteer wanted to translate the app, he got the XML file containing all the strings, translated it and sent it back to me.
But people who are not very familiar with computers tend to fail at that task: I often received the XML files back as Microsoft Word documents (.doc) or they translated the XML keys (which become the strings' IDs later) as well.
Therefore I recommend you to use some convenient tool for collaborative translation such as Transifex, crowdin or Get Localization.
You can even use a small website I've set up mainly for myself that offers Android translation as well if you don't want to pay for those services. It's not beautiful, but it should do everything you need.
I use the Notepad++ editor for manipulate xmls, it is very easy to use this application.
If you are looking for an automatic translation tool. I had created one and is available here.
I also created an android string translator and prepared a short video to explain how it works. This video can be opened at the indicated link from screencast. The link links to the location of the Excel file that runs the translation code. The file is code signed, free and ready to go.
https://app.screencast.com/3175zvrfOg6dZ?conversation=DJjUGfR9NPJLPAxLv3Hg5F&tab=Details
`
In Android Studio I developed nine hundred key string pairs relevant to my application.
Android encapsulates each of these strings in a particular format.
Android provides for different languages by retaining a key value and a translated value as part of a unique string. A list of strings needs to exist in the app, for all required languages.
The Program translated 907 strings into twelve different languages. These languages are English, Arabic, Bengali, Chinese, French, Hindi, Indonesian, Japanese, Korean, Portuguese, Russian, Spanish. The total count of strings is close to 11000.
This would be a formidable task if done manually and so a computerized process makes it easier.
These languages are now all set up in my android application.
An android user can choose one of eleven languages to use the application. The translations are based on the visual basic routines created in Microsoft excel. The program backcheck the translated words back into English. The translations do not always carry the intending meaning when backchecked.
For example, when the program translates the English string, False, into Bengali, the program produces a Bengali string. When the program backchecks the Bengali string to English, the result is the English word, lie. There is a connection to the original meaning.
I concluded that the program would be useable in another language. The user would need to pay attention these variations in nuance.

Categories

Resources