Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds language.json as the default entry point for i18n for crowdin integration #997

Merged
merged 3 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/lang/*
135 changes: 0 additions & 135 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"gulp-cssnano": "^2.1.3",
"gulp-rename": "^1.2.2",
"gulp-sass": "^4.0.1",
"hash-files": "^1.1.1",
"karma": "3.1.4",
"karma-babel-preprocessor": "6.0.1",
"karma-chai": "0.1.0",
Expand Down
1 change: 0 additions & 1 deletion scripts/build/gulp/_hash

This file was deleted.

70 changes: 12 additions & 58 deletions scripts/build/gulp/tasks/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@
const Constants = require('../constants');
const fs = require('fs');
const gulp = require('gulp');
const hashFiles = require('hash-files');
const path = require('path');
const walk = require('walk');

const hashSources = [
path.join(Constants.rootDir, 'lib', 'lang/*.js'),
Constants.ckeditorLangKeys,
path.join(Constants.langDir + '/*.json'),
];

const hashFile = path.join('./', '_hash');
const langWhitelist = /^\w\.js/;

/**
* Normalizes the different string values that can be stored in a language template.
Expand All @@ -31,7 +24,7 @@ const getStringLangValue = function(value, lang) {
return eval(value);
};

function updateLangFiles(callback) {
function buildLanguages(callback) {
// Mock the CKEDITOR.lang object to walk the ckeditor js lang files
global.CKEDITOR = {
lang: {},
Expand All @@ -52,6 +45,12 @@ function updateLangFiles(callback) {

// Iterate over every existing lang file inside src/lang
langWalker.on('file', (root, fileStats, next) => {
if (!langWhitelist.test(fileStats.name)) {
next();

return;
}

const lang = path.basename(fileStats.name, '.js');

// Load the matching CKEDITOR lang file with all the strings
Expand Down Expand Up @@ -89,7 +88,10 @@ function updateLangFiles(callback) {
fs.writeFile(
path.join(Constants.rootDir, 'src', 'lang', fileStats.name),
'AlloyEditor.Strings = ' +
JSON.stringify(AlloyEditor.Strings) +
JSON.stringify(AlloyEditor.Strings, null, 2).replace(
/^ /gm,
'\t'
) +
';',
err => {
if (err) {
Expand All @@ -101,54 +103,6 @@ function updateLangFiles(callback) {
});
}

function createHash(callback) {
hashFiles({files: hashSources}, (err, hash) => {
if (err) {
return callback(err);
}

fs.writeFile(hashFile, hash, err => {
if (err) {
return callback(err);
}
callback();
});
});
}

function compareHash(originalHash, callback) {
hashFiles({files: hashSources}, (err, hash) => {
if (err) {
return callback(err);
}

const changed = originalHash !== hash;
callback(changed);
});
}

function buildLanguages(callback) {
fs.exists(hashFile, exists => {
if (!exists) {
updateLangFiles(() => createHash(callback));
} else {
fs.readFile(hashFile, (err, data) => {
if (err) {
return callback(err);
}

compareHash(data.toString(), changed => {
if (changed) {
updateLangFiles(() => createHash(callback));
} else {
callback();
}
});
});
}
});
}

function copyLanguages() {
return gulp
.src(path.join(Constants.rootDir, 'src', 'lang', '/**'))
Expand Down
37 changes: 37 additions & 0 deletions src/assets/lang/language.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"add": "Add",
"ariaUpdateManyToolbars": "{toolbars} toolbars are available. Press ALT+F10 to focus.",
"ariaUpdateNoToolbar": "No toolbars are available",
"ariaUpdateOneToolbar": "{toolbars} toolbar is available. Press ALT+F10 to focus.",
"camera": "Insert Image from Camera",
"cameraDisabled": "The browser does not support this action, or it is available on https only (Chrome).",
"cite": "Cite",
"clearInput": "Clear Input Field",
"clear": "Clear",
"code": "Code",
"columns": "Cols",
"confirm": "Confirm",
"danger": "Danger",
"deleteEmbed": "Delete embed",
"disabled": "Disabled",
"editLink": "Type or paste link here",
"enterValidUrl": "Please enter a valid url",
"image": "Insert Image",
"info": "Info",
"link": "Link",
"linkTargetBlank": "_blank (new tab)",
"linkTargetDefault": "default",
"linkTargetParent": "_parent",
"linkTargetSelf": "_self (same tab)",
"linkTargetTop": "_top",
"normal": "Normal",
"pasteVideoLink": "Paste Video Link",
"platformNotSupported": "Sorry, this platform is not supported",
"primary": "Primary",
"removeLink": "Remove link",
"rows": "Rows",
"success": "Success",
"table": "Insert Table",
"videoPlaybackDisabled": "Video playback is disabled during edit mode",
"warning": "Warning"
}
1 change: 0 additions & 1 deletion src/lang/.prettierignore

This file was deleted.

Loading