I am working with an Arabic translator who is translating my strings.xml from english to arabic. I realize that only Honeycomb or Cyanogen roms will support arabic rendering, but that is ok.
Our problem is that the text keeps getting flipped around. It seems that some text editors (like Eclipse) blatantly do not support right-to-left text. And in some cases, the text is not flipped character by character, but word by word, or parts of the sentence get rearranged ... when copying from Microsoft Word back into the UTF-8 xml file.
For example, the translator supplied lines with spaces on each end, and naturally I wanted to clean these up. But doing so flipped some of the text around!
For example:
إغلاق التطبيق
became:
التطبيقإغلاق
just by removing spaces around the edges.
Questions:
1. What editor should I be using?
2. Is it ok to mix english and Arabic on the same line (such as the App Name or other words that should not be translated) or is this fundamentally a no-no?
I am currently working on an Arabic/English project, and I speek both languages, so I can provide you with my experience :)
Answer to Question 1:
Any editor that supports UTF8 will do. I am now using both eclipse and notepad++.
To setup eclipse with UTF8 (which is not the default for some reason), go to window menu -> preferences -> general -> workspace then change text file encoding from deault (cp1252) to other, and choose utf8, then restart eclipse.
For notepad++, ensure you install supported locales, including Arabic. It is not checked during instulation and you have to tick the checkbox to enable that feature.
Answer to Question 2:
It is absolutely fine to mix Arabic and English words together in a sentence. A very very good article I found about that is written here http://www.w3.org/International/tutorials/bidi-xhtml/
This article describes design concepts for sites that support right-to-left languages (including Arabic and Hebrew), with emphasis on Arabic due to it being a more complex language because some letters get connected to others and some do not.
Even though this article is talking about website design, it has a good amount of how Arabic and English languages should be mixed.
There a simple way to insert the right to left and left to right marks in any application under windows:
1- Right to left mark: ALT + 0254 from the right numeric pad in the keyboard
2- Left to Right mark: ALT + 0253 from the right numeric pad in the keyboard
Withouusing any special editors or macros, this can be used in any application, whether in Notepad, Word, HTML, XML... etc.
Hopefully, this would be helpful for everybody
Best regards
Your Arabic Translation Team
1- I developed few Android apps that support Arabic and I am using Notepad++ to edit the resources file without any problems. Just remember to select RTL from view menu (Ctrl+Alt+R).
Virtually all Android devices that support Unicode will display Arabic letters, but if bidi algorithm is not part of specific Android version you can use a custom library to connect letters and display Arabic correctly.
Here is a library that I used before
A Blog that describes how to use it
2- In general, I would not recommend mixing Arabic and English especially if it will involve special characters as it can be displayed awkwardly.
I know the Eclipse part, the default font in Eclipse doesnt support Unicode, So change it to "Aria Unicode MS" font. To do this in Eclipse workspace click on Windows in Menu Bar -> Preferences -> General -> Appearance -> Colors and Fonts. Now in the file explorer like menu in right, expand Basic, select "Text Font" and click on Edit.. button.
Hope this solves your viewing issue with Eclipse.
About Arabic app name issue, think on this, if you do localization correctly, then the Arabic name for app will be displayed only when the user changes the handset locale (and thus language) to Arabic, otherwise the default English app name will be displayed. So, just set the Arabic name in Arabic string.xml and English in the English one and you should be good.
As for editor part, there is no way to answer your question without knowing the platform. On Windows, standard Notepad should do.
For mixing strings, it is rather common scenario. It is typical that App Name won't get translated. Also, sometimes you need to put some English description in the brackets. You might need to play with strong directionality marks in such case (otherwise brackets would look a bit strange).
Related
I'm in the UK, I've created a strings.xml and different graphics for the US English speakers as they call animals by a different name and they spell things differently. I've noticed when creating my app the default in Android Studio is "en-us", how do I change this?
Now, the issue I am having is:
Our phones are set to English (United Kingdom)
They are showing the default images (not the "drawable-en_rUS" ones - USA)
But showing the "strings-en-rUS" strings rather than the default strings.
I've copied the default strings into a generic English folder ("strings-en" & drawable-en), but then in Android Studio if I choose "English(en)" from the drop down, it shows the US images and strings rather than the ones in the "-en" folders.
Clicking "Default(en-us)" in Android Studio then shows all the defaults (UK English).
Really confused by this, I'm assuming there should be a way to set Android Studio to "en-uk" but I cannot find it or anything online to help me. I'm wanting the defaults to be the main one so any other English speakers get the non-US spellings and words.
Any help appreciated.
Means, you want generic strings (UK) needs to be the default for everywhere that speaks English except for the US.
Copy all (UK) string in default string file and copy all (US) string to values-en-rUS directory and implement this code maybe it'll help you:
if(Locale.getDefault().country.equals("US")) {
val locale = Locale("en", "US")
Locale.setDefault(locale)
}
Use this code in start of the app, Application class might be best for it.
I am trying to display text in Indian regional languages on an Android app.
I've set up all the localization folders even though, I just want to have only one language for my app (say Punjabi).
In my strings.xml I have tried putting Hindi characters and Chinese characters and these are displayed correctly on the emulator. But when I put in Punjabi characters nothing shows up on the emulator.
Any reason for this? Can I overcome this problem?
I have the option of using a .ttf file in the assets folder for punjabi font. But that is not what I want to do because it does not give me complete control over the contents being displayed. Each .ttf behaves differently.
Any help is truly appreciated.
There is no support for local Indian languages on Android as yet. Hence the UTF-8 characters that fall outside the acceptable range for Android are ignored. Hence we see a blank being displayed.
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.
I am maintaining an Android app that people use to display strings in various exotic languages like Tibetan or old Greek. Because Android devices come with very few fonts, users can put font files on the SD card, and the app will use them.
QUESTION: Given a string, how can I automatically decide which font file is the most appropriate, so that this string appears without characters being replaced with squares/boxes?
Notes:
Each string is in one language.
Strings are displayed in a WebView.
Custom fonts work, the only problem is deciding which font file to use.
Instead of a single font, it could provide a list of fonts that are acceptable for that string.
Unnecessary context, for the curious: I am trying to develop this feature:
http://code.google.com/p/ankidroid/issues/detail?id=779
UPDATE: I ended up creating the Antisquare Open Source library based on Mostafa's idea.
It has a getSuitableFonts method which is blazingly fast.
Android by itself does not provide enough for such a task. Loading and rendering fonts in Android happens in Skia, which is written in C. Skia detects if a character can't be found in a font and falls back to another font for such characters (not the whole string). That's how Japanese, Hebrew, or Arabic text is shown in Android and that's exactly why these scripts don't have bold face! (Their font is selected through fallback and fallback only selects one font file.)
Unfortunately, this mechanism is not provided in APIs and you have to build similar thing on your own. It seems complicated, but is easier than it looks. All you have to do is:
Prepare lists of characters available in each font file.
For every string find the font that has more characters of the string.
Getting list of characters in each font
You don't have to do this on-the-fly in your Android app. You can prepare the list of characters in each font and put these lists in your app. I say that because this is way easier with tools that may not be available in Android. I would do that through Python scripting in a font app (most serious font tools have awesome Python scripting environments), but these apps are expensive and are for serious type designers. Since you're an Android developer, I recommend using sfntly, a library in Java and C++. Doing what you need (getting a list of Unicode characters available in a font file) is easy with sfntly. This sample works with CMap tables (tables that hold character to glyph mapping) and should be a good starting point for you.
Now the interesting part is that snftly is in Java and you may be able to include that in your Android app and do everything automatically. That's awesome by I recommend you start by getting familiar with snftly.
Selecting the font
After the previous part you'll have a list of Unicode character for every font, and based on these lists selecting the font file that provides most characters of every string is trivial.
First, sorry for my poor language skills.
I tried to modify the SearchableDictionary v2 sample from here: http://developer.android.com/resources/samples/SearchableDictionary/index.html
I need this for a school project.
I replaced the definitions in dev/raw/definitons.txt with some other definitions, which was written in Cyrillic, but now when I run the project and search for a word it doesn't show me word I was searching for.
However, if I enter some words in Latin symbols in definitions.txt, then the app works great, but when I put some words in Cyrillic it doesn't show me the words, when I search for them.
I assume that this is due to some encoding issues?
Thanks!
It could be due to encoding. In Eclipse, right click on the definitions.txt file and select properties. There you should see an option to specify the charset. Make sure its set to whatever you need (probably UTF-8)