This workshop will be retired on May 1, 2025.
Heads up! To view this whole video, sign in with your Courses Plus account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
In this video we'll finish up by adding Arabic to the app!
Arabic Strings
<resources>
<string name="app_name">ملك الطلاء</string>
<string name="buy">يشترى</string>
<string name="purchase_message">%1$sتاريخ التسليم المتوقع</string>
<string name="black">أَسْوَد</string>
<string name="blue">أَزْرَق</string>
<string name="gray">رَمَادِي</string>
<string name="green">أَخْضَر</string>
<string name="orange">بُرْتُقَالِي</string>
<string name="purple">بَنَفْسَجِي</string>
<string name="red">أَحْمَر</string>
<string name="white">أَبْيَض</string>
</resources>
Related Links
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Now that we're correctly formatting
our dates for our Spanish audience.
0:00
It's time to move on to
localizing our app for Egypt.
0:03
Just like last time we'll need to
start by translating RUI strings.
0:07
And since the main language
in Egypt is Arabic,
0:10
we'll need to translate
our strings to Arabic.
0:13
Unfortunately I don't know
much about Arabic, so
0:16
translating this is going
to be a bit of a challenge.
0:18
But luckily we don't have to do
all the translations ourselves,
0:21
thanks to Google we've actually got access
to some professional translators, and
0:25
yes that means it costs money.
0:29
But let's take a look at it anyway, so
0:32
that if the time comes that you need
a translation, you'll be ready.
0:34
The first thing we want to do is make sure
that our strings.xml file is ready for
0:38
a translator to look at it.
0:42
That means we should add some context
around our strings to let the translator
0:44
know how the strings will be used.
0:48
Over in our strings.xml file an example
of this would be the buy string.
0:50
Let's add the one above where we set
the buy string and then add a comment.
0:55
And inside that comment let's write
this is the label for the buy button.
1:03
It should not exceed seven characters.
1:11
And now when someone is translating this
for us, they'll know what the string is
1:17
used for, and they;ll know
that it has a size constraint.
1:21
Another thing we can do
to make life easier for
1:25
translators is to call out any part of our
strings that don't need to be translated.
1:27
An example of this would be the %1$s,
placeholder, and our purchase message.
1:32
If you're not familiar with this syntax,
1:37
it's just a placeholder
that we'll fill in later.
1:40
If we flip over to main activity
we can see how it's used
1:42
in the buy buttons on click listener.
1:46
Back in strings.xml, we really don't
want that part to be translated and
1:48
actually there's a standard way to mark
parts of our strings that we don't want
1:54
translated and that is the xliff:g tag.
1:58
So right before the percent
sign let's type <xliff:g.
2:02
And then use Alt Enter to
import the one from urn:oasis.
2:09
Then let's give this an id of date,
and then let's close this opening tag.
2:14
Finally let's add a closing
xliff:g tag after our placeholder.
2:23
Now when we submit our strings for
2:30
translation the translator will
know to ignore a placeholder.
2:31
Speaking of submitting for translation,
over in the project pane lets right
2:35
click on string.xml and
choose open translations editor.
2:39
Then, let's click on Order a translation.
2:45
And now, we're brought to a website
where we can order a translation.
2:48
So let's select the Source Language
of English, and then let's drag and
2:51
drop in our strings.xml file.
2:56
And then, hit Next.
3:02
Then let's pick Arabic,
and hit Next again.
3:04
And now we've just got to pick a service
provider and order a translation.
3:09
And in about a week, we'll have all of our
strings translated into a new language.
3:14
Pretty cool, right?
3:19
Now let's pretend it's a week later and
3:21
we've just gotten back
our Arabic translations.
3:22
Let's create a new values resource file.
3:26
And again let's name it Strings.
3:30
Then let's add the locale qualifier.
3:33
And for the language, let's pick Arabic.
3:37
Finally let's copy and paste in the Arabic
strings from the teacher's notes below.
3:41
Then let's run the app.
3:48
And change the language to Arabic.
3:51
Which is this one.
3:58
And immediately the UI changes from
left to right to right to left.
4:00
This is why it's so
important to use gravity.start and end,
4:05
instead of gravity.left and right.
4:09
Now let's use the recent apps
button to jump back to our app.
4:12
And all right,
the app is now in arabic and
4:14
the navigation drawer even
comes in from the right.
4:20
Awesome, and if we pick a color the price
is formatted appropriately too.
4:23
And clicking the buy button,
it looks like we've got a date in there.
4:29
Nice, our app is now ready for
market in Spain and Egypt.
4:33
But that doesn't mean we're done with our
localization effort to really localize
4:37
an app you not only need to
localize the app itself, but
4:42
you also need to localize the place
you're listing for your app.
4:44
You'll need to get
different screenshots for
4:48
different languages and even update
all of the promotional graphics too.
4:50
Once that's done,
4:54
you'll probably also want to run
a beta test before launching the app.
4:55
Doing a beta first is
always a best practice, but
4:59
it's especially important when
it comes to localization.
5:02
When you aren't a native
speaker of a language,
5:06
it's pretty tough to know that
you got a good translation.
5:08
And having local native speakers
test your app before you release it
5:11
is just a good idea.
5:15
Localizing an app can be a lot of work,
but if you've got a large audience and
5:17
a country that you don't yet support, not
only are your users not getting the best
5:21
possible experience but you could be
missing out on a lot of new revenue.
5:25
And especially since Google's made
this process so easy there's fewer and
5:30
fewer reasons to not localize your app.
5:34
Hopefully, this is giving you
a pretty good idea of how to support
5:36
all kinds of locales all around the world.
5:39
And if you've got any questions or
5:42
ideas about localizing an app be
sure to post them in the community.
5:44
Until next time.
5:48
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up