سؤال

I guess the title is self-explanatory.

هل كانت مفيدة؟

المحلول

You can extract localization from Android .xml file then add it to iPhone .string file with last version of TM-database tool. It is easy:

  1. Launch tool
  2. Open source and target Android xml files and import localization to TM
  3. Open .string file and translate it with TM
  4. Save .string file

Please see the detail instruction here

نصائح أخرى

I was just looking at this as well. If you just need something to get some of the grunt work done, and you're on OsX already, you can use xsltproc and this simple xsl to get you going

The xsl:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="string">
"<xsl:value-of select="@name"/>"= "<xsl:apply-templates/>"; </xsl:template>
<xsl:template match="resources">
<xsl:apply-templates select="string"/> </xsl:template>
</xsl:stylesheet>   

Save this to a file, transform.xsl or something, then from a shell run the following:

xsltproc transform.xsl your_android_strings.xml > fileforxcode.out

This seemed to generate something that looked right, although you'll probably need to muck with any format strings separately. No matter what, it might save you some work.

I use a script here. It converts the already-translated Android localized strings files into iOS Localizable.strings files, accounting for conversions of string placeholders (%1$sbecomes %1$@). Its a short ruby script and is easy to follow. Link it into Xcode as a Run Script at the beginning of your build process.

You also have this option if you don't want to preprocess the strings but just drop the android strings.xml file into the iPhone project.

This don't really answer your question but you may consider DMLocalizedString for your future iOS+Android project. Currently the source is for iOS only, but I believe that making the Android version is pretty easy.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top