Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if Localizable.strings file is valid

I am creating Localizable.strings file programatically. I am downloading the file from server and showing the localization from that file.

But if there is some error in file then my localization don't work. It shows me the keys. If on server I edit the localization file and I added string as

"HELLO_WORLD" = Hello

Here, the key is correct but value is not in correct format. The format should be as

"HELLO_WORLD" = "Hello";

How can I programatically check at runtime if my Localizable.strings file does not contain any error and is valid?

like image 634
Chetan Avatar asked Aug 21 '15 07:08

Chetan


2 Answers

Use plutil from the Terminal:

plutil -lint Localizable.strings
like image 66
Aderstedt Avatar answered Oct 12 '22 15:10

Aderstedt


In addition to @Aderstedt's answer:

plutil -lint Localizable.strings does work, but you have to run it for each version of the file. E.g

  1. cd into your project root
  2. cd en.lproj - you can replace this with any localisation you are working with.
  3. plutil -lint Localizable.strings

When you run step 3, you will either be shown an error, telling you what is wrong with your file. Or you will be told the file is OK

like image 38
JackColley Avatar answered Oct 12 '22 15:10

JackColley