Giter Club home page Giter Club logo

fame's Introduction

Fame logo

Delightful localization of .storyboard and .xib files, right within Interface Builder. Fame makes it easy to enable specific Interface Builder elements to be translated and exported to localizable .xliff files.

Introduction

Compared to localization in code (NSLocalizedString), Storyboard and XIB localizations are a tedious task for both developers and translators.

Static vs. dynamic localization

Storyboard and XIB files usually contain a mixed set of elements with static or dynamic text:

  • Static text: Elements with fixed localization strings that will never change at runtime
  • Dynamic text: Elements that will change their localized text during runtime. For example a label that is populated with data from an API or a status label that is populated using NSLocalizedString at runtime.

Static text elements should be localized using a generated .xliff file, dynamic text elements should be ignored during translation.

However, Storyboard and XIB .xliff files generated by Xcode also contain dynamic text localizations that will always be overridden at runtime. This makes it hard to distinguish between localizations that should be translated and dynamic text that can be safely ignored during translation. It's up to the app developers to either manually remove generated localizations that should not be translated, or leave them for the translators to waste their time with.

Localization comments

Storyboard and XIB .stings files generated by Xcode do not provide a useful comment that provides context to the translator.

<trans-unit id="si2-WH-Hr5.text">
  <source>Dynamic label 2</source>
  <target>Dynamic label 2</target>
  <note>Class = "UILabel"; text = "Dynamic label 2"; ObjectID = "si2-WH-Hr5";</note> <-- ๐Ÿ™„
</trans-unit>

Translators use this comment to make sure their translation fits into the context it is used in. Its again up to the app developers to either manually search for specific translations and add a comment, or leave let the translators figure out how to find the best translation without context.

Why Fame?

Fame solves the above mentioned issues to help developers and translators get the most out of tedious localization tasks.

Integrated into Interface Builder

Fame makes it easy for developers to specify which elements of your Storyboard and XIB files should be translated, all right within interface builder. Developers may also add a comment for each element to provide additional context to translators.

Interface Builder Integration

Command Line Interface

Using the fame CLI, developers can export .xliff files that only contain localizations for elements previously enabled in Interface Builder.

fame CLI

Generates beautiful .xliff files

Translators only receive the strings that should actually be translated, saving them time (and you potentially lots of money). All generated .xliff files also contain each element's name and a useful comment to provide more context by the app developer.

<trans-unit id="si2-WH-Hr5.text">
  <source>Dynamic label 2</source>
  <target>Dynamic label 2</target>
  <note>Explains how to purchase a pro subscription.</note> <-- ๐Ÿ˜
</trans-unit>

Installation

Install the fame ruby gem using your terminal to get access to the fame command line interface.

$ gem install fame

Enable localization for Interface Builder files

Note: You may skip to the next section if you have already setup your project and Interface Builder files for localization.

First off, add all supported languages to your project. This can be done by clicking the + button under your project's Localizations configuration. Go ahead and add as many languages as you want.

Add new language to project

Next, make sure to enable localization for your Interface Builder files and choose the "Localizable Strings" option from the dropdown.

Add new language to project

You should now have a Base Interface Builder file (e.g. Main.storyboard) in a Base.lproj folder and multiple localizable strings files (e.g. Main.strings) each within a language folder (e.g. en.lproj and de.lproj).

Add new language to project

That's it, read on to enable fame for localization.

Setup Fame for Interface Builder

In order to enable the Interface Builder integration to specify the elements that should be translated, add the Fame.swift file to your Xcode project. To test the Interface Builder integration, open any Interface Builder file in your project, select an element (e.g. a UILabel) and you should see a new section that lets you configure localization for this element in the Attributes inspector.

Interface Builder Integration

You can now enable localization for each element you want to have translated.

Usage

Once all localizable elements have been configured in Interface Builder, you can export the localizable .xliff file using the fame command line tool.

First, make sure to commit all local changes, just to be safe. Then open terminal, navigate to the root folder of your project and run

$ fame --project Example.xcodeproj [--ib-file-path] [--output-path]

In a nutshell, the fame command does the following:

  • Find all .storyboard and .xib files in the current folder (recursively, you can also pass a subpath or file to the fame command)
  • Lookup the localizable settings (you have set in Interface Builder) for each file
  • Generate the full localizable .xliff file using Apple's xcodebuild
  • Filter the xcodebuild output based on your localizable settings
  • Add useful comments according to your settings
  • Save changes

Contributing

  1. Fork it ( https://github.com/aschuch/fame/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

TODO

  • Write tests with fixtures

Contact

Feel free to get in touch.

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.