Localization support- automatically export all words

Dear all,


I would like to support multiple languages for my iOS application.


I was wondering if I can export automatically all the words and sentences are coming both from Interface Builder and from NSLocalizedStrings being written in .m files as XLIFF files, provide these files for translations and then import these XLIFF files back to my iOS project.


Similar to the article https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPInternational/LocalizingYourApp/LocalizingYourApp.html

but for the iOS and not for MacOS. Is it possible?


Regards,

kalgik

Answered by QuinceyMorris in 246758022

Can you import the XLIFF files other than English? It may be an issue with base localization vs. localization in the base/development language.

It works essentially the same way on macOS and iOS. Have you run into a specific difficulty?

Yes.


I exported the XLIFF from Editor->Export for localization, I select development language (EN) and the en.xliff is created.

I do the same for other languages e.g. EL, ES, IT.


I translate the el.xliff, es.xliff and it.xliff and then I would like to import to my iOS project.

I select Editor-> Import Localizations-> select file e.g. en.xliff, el. xliff but I receive the following error:

"The XLIFF file does not contain a target language".


All of these languages have been added int the Project -> Info -> Localization.


Regards,

kalgik

Accepted Answer

Can you import the XLIFF files other than English? It may be an issue with base localization vs. localization in the base/development language.

Yes, the problem was with English because is the development language.


I saw the xliff generated. It is clear for me which is the text.

However, I do not think that it could be easily understood by a translator which words/sentences can be translated.


<trans-unit id="1aI-qb-GuL.placeholder">
        <source>Pets allowed</source>
        <note>Class = "UITextField"; placeholder = "Pets allowed"; ObjectID = "1aI-qb-GuL";</note>
      </trans-unit>
      <trans-unit id="1av-dj-pqP.normalTitle">
        <source>SIGN IN</source>
        <note>Class = "UIButton"; normalTitle = "SIGN IN"; ObjectID = "1av-dj-pqP";</note>
      </trans-unit>
</trans-unit>
      <trans-unit id="3VG-rL-YdP.normalTitle">
        <source>Already have an account?</source>
        <note>Class = "UIButton"; normalTitle = "Already have an account?"; ObjectID = "3VG-rL-YdP";</note>
      </trans-unit>
      <trans-unit id="3md-IT-54w.title">


Shall I use the other way? Shall I create Main.string automatically

* Class = "UIButton"; normalTitle = "Button"; ObjectID = "1u9-Yp-CXu"; */
"1u9-Yp-CXu.normalTitle" = "Button";
/ Class = "UILabel"; text = "Label"; ObjectID = "6ZI-Yx-jOP"; */
"6ZI-Yx-jOP.text" = "Label";
/ Class = "UILabel"; text = "Hello my name is Kostas."; ObjectID = "HOA-tU-nyv"; */
"HOA-tU-nyv.text" = "Hello my name is Kostas.";
/ Class = "UILabel"; text = "Label"; ObjectID = "PYK-cg-Jc9"; */
"PYK-cg-Jc9.text" = "Label";

and manually the Localizable.string files?

"Change language" = "Change language";


What do you think?


Regards,

kalgik

It should be obvious to a translator who's familiar with XLIFF, which text should be translated. Presumably there are editing tools out there to help with this.


Note that there are two sources of unlocalized text in XLIFF files:


1. Text you used in code with NSLocalizedString (…), which specifies both the (base) text and a comment to guide the translator. (You can either have be the base text be in the base language, or be an arbitrary unique string that therefore needs to be localized into the base language. Which one you choose depends on the complexity of your project, I guess.)


2. Text you used in your UI, such as buttons and labels in your storyboard. If you look in the Identity inspector, you'll see there's a "comment for localizer" text field down the bottom, which you can use to supply comments for these. It's unusual (I think) for this text to be in anything other than the base language.

Thank you.


I already found some editing tools in the internet which I am going to recommend.


Regards,

kalgik

Another issue came up.


I have posted as a differenent subject. Here : https://forums.developer.apple.com/thread/83079

I am trying to import the translated .xliff files but Localizable.strings, Main.strings and Infoplist.strings are empty.

Any idea?


Regards,

kalgik

Localization support- automatically export all words
 
 
Q