Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ilib-loctool-webos-qml

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ilib-loctool-webos-qml - npm Package Compare versions

Comparing version 1.3.7 to 1.4.0

6

package.json
{
"name": "ilib-loctool-webos-qml",
"version": "1.3.7",
"version": "1.4.0",
"main": "./QMLFileType.js",

@@ -50,9 +50,9 @@ "description": "A loctool plugin that knows how to process qml files",

"dependencies": {
"ilib-loctool-webos-ts-resource": "1.3.0"
"ilib-loctool-webos-ts-resource": "1.3.1"
},
"devDependencies": {
"assertextras": "^1.1.0",
"loctool": "2.18.0",
"loctool": "2.20.0",
"nodeunit": "^0.11.3"
}
}

@@ -20,5 +20,7 @@ /*

var fs = require("fs");
var path = require("path");
var QMLFile = require("./QMLFile.js");
var TSResourceFileType = require("ilib-loctool-webos-ts-resource");
var ResourceString = require("loctool/lib/ResourceString.js");

@@ -30,3 +32,3 @@ var QMLFileType = function(project) {

this.extensions = [ ".qml", ".js"];
this.isloadCommonData = false;
this.project = project;

@@ -67,2 +69,5 @@ this.API = project.getAPI();

if (project.settings.webos && project.settings.webos["commonXliff"]){
this.commonPath = project.settings.webos["commonXliff"];
}
};

@@ -117,3 +122,9 @@

}.bind(this));
var customInheritLocale;
if (this.commonPath && !this.isloadCommonData) {
this._loadCommonXliff(translationLocales);
this.isloadCommonData = true;
}
for (var i = 0; i < resources.length; i++) {

@@ -124,10 +135,68 @@ res = resources[i];

this.logger.trace("Localizing QML strings to " + locale);
customInheritLocale = this.project.getLocaleInherit(locale);
db.getResourceByCleanHashKey(res.cleanHashKeyForTranslation(locale), function(err, translated) {
var r = translated;
if (!translated) {
var manipulateKey = res.cleanHashKeyForTranslation(locale).replace(res.getContext(),"");
var manipulateKey = res.cleanHashKeyForTranslation(locale).replace(res.getContext(), "");
db.getResourceByCleanHashKey(manipulateKey, function(err, translated) {
var r = translated;
if (!translated || ( this.API.utils.cleanString(res.getSource()) !== this.API.utils.cleanString(r.getSource()) &&
if (!translated && this.isloadCommonData) {
var manipulateKey = ResourceString.hashKey(this.commonPrjName, locale, res.getKey(), this.commonPrjType, res.getFlavor());
db.getResourceByCleanHashKey(manipulateKey, function(err, translated) {
if (translated) {
translated.project = res.getProject();
translated.datatype=res.getDataType();
translated.pathName = res.getPath();
translated.context = res.getContext();
file = resFileType.getResourceFile(locale);
file.addResource(translated);
} else if(!translated && customInheritLocale){
db.getResourceByCleanHashKey(res.cleanHashKeyForTranslation(customInheritLocale), function(err, translated) {
if (translated){
translated.setTargetLocale(locale);
file = resFileType.getResourceFile(locale);
file.addResource(translated);
} else {
var newres = res.clone();
newres.setTargetLocale(locale);
newres.setTarget((r && r.getTarget()) || res.getSource());
newres.setState("new");
newres.setComment(note);
this.newres.add(newres);
this.logger.trace("No translation for " + res.reskey + " to " + locale);
}
}.bind(this));
} else {
var newres = res.clone();
newres.setTargetLocale(locale);
newres.setTarget((r && r.getTarget()) || res.getSource());
newres.setState("new");
newres.setComment(note);
this.newres.add(newres);
this.logger.trace("No translation for " + res.reskey + " to " + locale);
}
}.bind(this));
} else if (!translated && customInheritLocale) {
var manipulateKey = res.cleanHashKeyForTranslation(customInheritLocale).replace(res.getContext(),"");
db.getResourceByCleanHashKey(manipulateKey, function(err, translated) {
var r = translated;
if (translated){
var storeResource = r.clone();
storeResource.pathName = res.getPath();
storeResource.context = res.getPath().replace(/^.*[\\\/]/, '').replace(/\.(qml|js)/, "");
storeResource.setTargetLocale(locale);
file = resFileType.getResourceFile(locale);
file.addResource(storeResource);
} else {
var newres = res.clone();
newres.setTargetLocale(locale);
newres.setTarget((r && r.getTarget()) || res.getSource());
newres.setState("new");
this.newres.add(newres);
this.logger.trace("No translation for " + res.reskey + " to " + locale);
}
}.bind(this));
} else if (!translated || ( this.API.utils.cleanString(res.getSource()) !== this.API.utils.cleanString(r.getSource()) &&
this.API.utils.cleanString(res.getSource()) !== this.API.utils.cleanString(r.getKey()))) {

@@ -219,2 +288,27 @@ if (r) {

QMLFileType.prototype._loadCommonXliff = function() {
if (fs.existsSync(this.commonPath)){
var list = fs.readdirSync(this.commonPath);
}
list.forEach(function(file){
var commonXliff = this.API.newXliff({
sourceLocale: this.project.getSourceLocale(),
project: this.project.getProjectId(),
path: this.commonPath,
});
var pathName = path.join(this.commonPath, file);
var data = fs.readFileSync(pathName, "utf-8");
commonXliff.deserialize(data);
var resources = commonXliff.getResources();
var localts = this.project.getRepository().getTranslationSet();
if (resources.length > 0){
this.commonPrjName = resources[0].getProject();
this.commonPrjType = resources[0].getDataType();
resources.forEach(function(res){
localts.add(res);
}.bind(this));
}
}.bind(this));
};
QMLFileType.prototype.newFile = function(path) {

@@ -322,2 +416,2 @@ return new QMLFile({

module.exports = QMLFileType;
module.exports = QMLFileType;

@@ -5,2 +5,23 @@ # ilib-loctool-webos-qml

## Release Notes
v1.4.0
* Updated dependencies. (loctool: 2.20.0)
* Added ability to define custom locale inheritance.
* i.e) en-AU inherits translations from en-GB
~~~~
"settings": {
"localeInherit": {
"en-AU": "en-GB"
}
}
~~~~
* Added ability to use common locale data.
* App's xliff data has a higher priority, if there's no matched string there, then loctool checks data in the commonXliff directory.
~~~~
"settings": {
"webos": {
"commonXliff": "./common"
}
}
~~~~
v1.3.7

@@ -7,0 +28,0 @@ * Updated dependencies. (loctool: 2.18.0)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc