Making sure your strings file is cleaned up before sending it to your translators can cut down on the time spent in communication with them. In this video, learn about a few ways to make the translation process easier.
- [Narrator] Let's talk about a few things we can do to make our strings easier to get translated. Let's open up our plurals dot xml file again. And see here we have strings that are inside of this file, outside of our main strings dot xml file. So because they're in two different files it may be a little harder to get translations. We'll have to send both of these files to the translators. But we can actually use a little trick here to make this easier for us. So in this plurals file, let's just copy out this string and go to our main strings dot xml file.
And at the bottom we'll add a new string. And we'll call it comment one. And we'll have the text of the string be the text that we copied out of the plurals file. Now back in the plurals file, instead of hard coded text, we can just reference that string resource that we just created. Comments underscore one. Then if you do this with all of the strings inside this file, then you still only need to give your strings set xml file to your translators.
And your plurals file will update automatically. When giving your strings to your translators you may want to add some context to it. So think of it from the translators perspective. If they just look at your strings file and see payment underscore credit on the string here at the top. And then credit card in English, how do they know where the string will be used and what it will be used for? Maybe the width of that word is exactly how much space that you have in the layout file, but your German translator provides you with a long translation in its' place.
You can help solve these problems ahead of time by providing context to your strings with a simple xml comment above the string. So let's go ahead and add that. Just click enter to add an extra line here. Then we can add an xml comment, which is just open caret, exclamation point, and two dashes. And then two dashes and a closed caret to close it. So when we're adding context, consider providing information like, what is the string used for? Where is it in a layout? Or how many characters do you have to work with? So here we'll say, this is in a list of payment options.
And we have 12 to 15 characters worth of space. One more thing to think about when internationalizing your strings, is that not all of your strings are going to be translatable. Take, for instance, your Facebook app ID. Let's scroll up a little bit to see that. You may store this in your strings file so you can swap it out in your dbug and release builds, but you don't want it to show up in your lint results when you're checking to see what strings haven't been translated. So to indicate that your string is not translatable, you can add another property to this xml mode here.
Just translatable is false. And now the lint check will ignore that this string is not translated. These sorts of things may take some extra time up front, but once you start interacting with translators, you'll see that it saves you time in the long run.
- The localization process
- Basic internationalization
- Choosing target markets
- Preparing your app for internationalization
- Translating your app
- Testing and releasing your translated app