Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this questionI'm asking myself a couple of questions开发者_JAVA技巧 and im wondering if there are any best practices.
- How to name the string? It's always ending in chaos for me.
- How to keep translations in sync? Are there collaborative online tools you can recommend?
- How to order the string in the
strings.xml
file? Alphabetical? Grouped by Activity? ...? - What about reusing strings? Would you recommend using multiple slightly different string or one string that somehow fits in multiple contexts?
I'm still new at this, so I was looking for an example project. Astrid is open source on Github, and looking through the projects res directory was eye opening for a newbie like me.
Good stuff. Take a look:
https://github.com/todoroo/astrid/tree/master/astrid/res/values
Nice question. Im struggling with this too. My naming scheme is:
1) UI elements: If a string only corresponds to a ui i name it accordingly to the control element and the purpose, as well as in which part of the control element it is used. example:
button_helpText;
control : button, purpose: help, context: Text;
2) General elements: If a string is used on the UI but i want to use it in another context i just leave the prefix and add a postfix to describe the purpose / context mor precise.
helpMessageHeading;
purpose: help; context: a Message (abstract, could be a dialog), context_of_dialog: Heading; (the heading of a help dialog)
helpMessageText;
purpose: help, context: a Message (abstract, could be a dialog), context_of_dialog: Text; (the text inside a help dialog)
helpExplanation;
purpose: help; context_of_help: Explanation (just a explanation of the help topic)
3) Ordering: I order those string mainly based on their context as it is what you normally search for.
<!-- buttons -->
...
<!-- dialogs -->
...
<!-- general -->
...
<!-- explanations -->
...
and so on. So my list is normally seperated in UI controls and, if a string is not bound to it, its general precise context. Why do i use the precise context ? when you search for a string to describe what you do the most unique idea about this string is its precise context, so thats what should pop up first. But when you use auto-completion you normally search for the general description. i think this structure is a fine solution.
I im very interested in other answers.
The best place to check out conventions would most likely be within the Android SDK samples. Here's how you can find them -http://developer.android.com/tools/samples/index.html
How to keep translations in sync? Are there collaborative online tools you can recommend?
For me, the best tool is http://www.translatekarate.com
It is free and collaborative.
How to keep translations in sync? Are there collaborative online tools you can recommend?
At the moment I'm using this collaborative tool http://www.getlocalization.com/ which makes life a lot more easier and is free if using no pro features.
Then there is also https://crowdin.com/ which is a bit better in my opinion becuse ist proposes translations by google and bing but costs 9$ in the cheapest variant.
How to order the string in the strings.xml file? Alphabetical? Grouped by Activity? ...?
Up to now, I didn't order them because I mostly don't edit my xml by hand. There is a plugin which makes handling multiple translations in eclipse very easy: Sequoyah localization Editor
How to keep translations in sync? Are there collaborative online tools you can recommend?
I use the project management tool https://poeditor.com to translate XML files and keep them in sync.
精彩评论