I am getting Bad entry in file
error when using genstrings
command line for every call to NSLocalizedString
that uses tableName
parameter
See the following example when trying to generate localized strings (from Firefox-iOS)
find . -name *.swift | xargs genstrings -o en.lproj
Bad entry in file ./StorageTests/TestSQLiteHistory.swift (line = 100): Argument is not a literal string.
Bad entry in file ./StorageTests/TestSQLiteHistory.swift (line = 101): Argument is not a literal string.
Bad entry in file ./StorageTests/TestSQLiteHistory.swift (line = 102): Argument is not a literal string.
Bad entry in file ./StorageTests/TestSQLiteHistory.swift (line = 103): Argument is not a literal string. Argument is not a literal string.
Here is the code for these lines
let titleMobile = NSLocalizedString("Mobile Bookmarks", tableName: "Storage", comment: "The title of the folder that contains mobile bookmarks. This should match bookmarks.folder.mobile.label on Android.")
let titleMenu = NSLocalizedString("Bookmarks Menu", tableName: "Storage", comment: "The name of the folder that contains desktop bookmarks in the menu. This should match bookmarks.folder.menu.label on Android.")
let titleToolbar = NSLocalizedString("Bookmarks Toolbar", tableName: "Storage", comment: "The name of the folder that contains desktop bookmarks in the toolbar. This should match bookmarks.folder.toolbar.label on Android.")
let titleUnsorted = NSLocalizedString("Unsorted Bookmarks", tableName: "Storage", comment: "The name of the folder that contains unsorted desktop bookmarks. This should match bookmarks.folder.unfiled.label on Android.")
When I searched for a solution I found this tool for generating and merging localized strings. It worked for this case, generated and merged the localized strings into Localizable.strings
but in run time the app does not show the localized titles as it tries to load the localized strings form a file with the a name Storage.strings
not from Localizable.strings
Is there is any solution to automatically generate these files instead of doing it manually?
It seems that I need to translate the resources according to the latest procedure from apple
.xliff
using Xcode (select your Project in Xcode, then Editor -> Export for Localization)