문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top