Add optional argument 'language' to getStrings in iOS

This commit is contained in:
Ruben Gonzalez Alonso
2014-04-29 12:38:09 +02:00
parent 858b4a30e9
commit dbf5868c79
2 changed files with 21 additions and 10 deletions

View File

@@ -466,14 +466,15 @@ iOSController.toggleLocationServices = function (cb) {
};
iOSController.getStrings = function (language, cb) {
if (language) logger.warn("Language parameter is not implemented in iOS");
var strings = this.localizableStrings;
if (strings && strings.length >= 1) strings = strings[0];
this.parseLocalizableStrings(function() {
var strings = this.localizableStrings;
if (strings && strings.length >= 1) strings = strings[0];
cb(null, {
status: status.codes.Success.code
, value: strings
});
cb(null, {
status: status.codes.Success.code
, value: strings
});
}.bind(this), language);
};
iOSController.executeAtom = function (atom, args, cb, alwaysDefaultFrame) {

View File

@@ -956,13 +956,23 @@ IOS.prototype.setDeviceAndLaunchSimulator = function (cb) {
}
};
IOS.prototype.parseLocalizableStrings = function (cb) {
IOS.prototype.parseLocalizableStrings = function (cb, language) {
if (this.args.app === null) {
logger.info("Localizable.strings is not currently supported when using real devices.");
cb();
} else {
var strings = path.resolve(this.args.app, "Localizable.strings");
var strings = null;
if (language) {
strings = path.resolve(this.args.app, language + ".lproj", "Localizable.strings");
if (!fs.existsSync(strings)) {
logger.info("No Localizable.strings for language '" + language + "', getting default strings");
}
} else if (this.args.language) {
strings = path.resolve(this.args.app, this.args.language + ".lproj", "Localizable.strings");
}
if (!fs.existsSync(strings)) {
strings = path.resolve(this.args.app, "Localizable.strings");
}
if (!fs.existsSync(strings)) {
strings = path.resolve(this.args.app, "en.lproj", "Localizable.strings");
}