localize existing iOS app

大兔子大兔子 提交于 2019-12-21 23:02:49

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/15692432/localize-existing-ios-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!