GithubHelp home page GithubHelp logo

localizabledemo's Introduction

LocalizableDemo

Localizable.Stirng

使用xliff 本地化

使用注意

1 、项目中需要使用以下语句进行本地化 。NSLocalizedString ,NSLocalizedStringFromTableInBundle。

2、新建Localizable.stirngs 文件(注意同名),并选中Localizabel.string文件,点击右边的Localiztion按钮。完成该步骤使NSLocalizedString 即使没有定义值时,返回该值id。

3、并在 PROJECT -> Info 中添加多种语言。

4、选中项目target -> Editor -> Export 得到xliff文件。 Xliff 文件的内容是跟据项目中NSLocalizedString语句自动生成的。

5、修改翻译选择后,target -> Editor -> Import 得到新的 Localizable.stirngs (注意NSLocalizedString 语句与xliff文件选择对应)

可以使用 xliff 工具查看,暂时没有找到免费的。

无法导出 英文的xliff文件(未知),可以不选择语言导出xliff文件。但导出内容缺少内容,需要手动补充。

测试代码

 [SoLangugeUnit saveCurrentLanguge:@"zh-Hans"];

 NSString *ss=  NSLocalizedStringFromTableInBundle(@"Apple", @"",[SoLangugeUnit localiableBundleFormCurrentLanguge],@"第一个参数为id 第二个参数为文件名(可以为空或Localizable) 第三个参数为语言 第四个参数备注");
    
 NSLog(@"result %@",ss);

xliff文件

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xliff xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
  <file source-language="en" original="LocalztionDemo/en.lproj/InfoPlist.strings" datatype="plaintext" target-language="en">
        <header>
      <tool tool-version="9.4.1" build-num="9F2000" tool-name="Xcode" tool-id="com.apple.dt.xcode"/>
    </header>
    <body>
      <trans-unit id="CFBundleName">
        <source>$(PRODUCT_NAME)</source>
        <note>Bundle name</note>
      </trans-unit>
    </body>
  </file>
  <file source-language="en" original="LocalztionDemo/en.lproj/Localizable.strings" datatype="plaintext" target-language="en">
        <header>
      <tool tool-version="9.4.1" build-num="9F2000" tool-name="Xcode" tool-id="com.apple.dt.xcode"/>
    </header>
    <body>
      <trans-unit id="APPLE">
        <source>APPLE</source>
        <target>APPLE</target>
        <note>No comment provided by engineer.</note>
      </trans-unit>
      <trans-unit id="APPLE1">
        <source>APPLE1</source>
        <target>APPLE1</target>
        <note>No comment provided by engineer.</note>
      </trans-unit>
      <trans-unit id="APPLE2">
        <source>APPLE2</source>
        <target>APPLE2</target>
        <note>No comment provided by engineer.</note>
      </trans-unit>
      <trans-unit id="APPLE3">
        <source>APPLE3</source>
        <target>APPLE3</target>
        <note>No comment provided by engineer.</note>
      </trans-unit>
      <trans-unit id="APPLE4">
        <source>APPLE4</source>
        <target>APPLE4</target>
        <note>No comment provided by engineer.</note>
      </trans-unit>
      <trans-unit id="APPLE5">
        <source>APPLE5</source>
        <target>APPLE5</target>
        <note>No comment provided by engineer.</note>
      </trans-unit>
      <trans-unit id="APPLE6">
        <source>APPLE6</source>
        <target>APPLE6</target>
        <note>No comment provided by engineer.</note>
      </trans-unit>
    </body>
  </file>
</xliff>

localizabledemo's People

Contributors

lingaoo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.