3

Is it possible to "preprocess" localization strings to substitute SOME_CONST with its predefined value?

For example, can I put some placeholder into my storyboards and localized strings and replace it on build time?

Its not about localizing but about preprocessing localization files or other resources with preprocessor`s constants.

Alexey Sidorov
  • 846
  • 1
  • 9
  • 17
  • You can certainly write a script to do that and add it as a pre-build step. Is string formatting not enough though? https://thatthinginswift.com/string-formatting – Aurast Sep 04 '15 at 13:57
  • look at my comment to this answer http://stackoverflow.com/a/32399934/1758481 – Alexey Sidorov Sep 04 '15 at 14:05

1 Answers1

2

Yes, you can do that

You may have a shell script phase that preprocesses the files before xcode uses them.


and no, I don't think there is a built in way

Community
  • 1
  • 1
Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
  • But it means that files would be changed during the processing, so I cant run in twice, cause my placeholders would be replaces and can`t use it to whitelabel, for example – Alexey Sidorov Sep 04 '15 at 14:03
  • 2
    @AlexeySidorov your build process could first copy the files to another location, make the string substitutions in those copied files, and then use the copied files as source for your build. – Aurast Sep 04 '15 at 14:59