Domanda

I can't believe this hasn't been asked before (either I'm too unorganized in my coding practices or I didn't use the right keywords): How can I localize an existing iOS app that doesn't use NSLocalizedString (specifically just the first step, converting all strings literals to NSLocalizedString)?

I understand how the localization process works, but I don't want to change all texts myself. Surely there must be a tool that can convert @"Hello World" to NSLocalizedString(@"Hello World", nil).

Sure I could do this manually with search and replace, but I can't believe there's no tool for this.

È stato utile?

Soluzione

I've wrote a xcode plugin to do this kind of job. Execute script is slow in xcode, so I did not choose to write s script to do it. Although writing Xcode plugin is kind of difficult, there is not official documentation, but after get used to it, it is fun to play with it.

Here is the link:

https://github.com/nanaimostudio/Xcode-Quick-Localization

Install:

  1. Build the project use Xcode.

Usage:

  1. Select multiple line, press Option+Shift+D

  2. if no selection, it will convert only current line.

Altri suggerimenti

I would write a simple bash script that searches for text

@"Your Text" 

and replaces it with

NSLocalizedString(@"Your Text", nil);

They can be really powerful things

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top