mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-29 02:59:58 +02:00
?locale=ja-JP
This commit is contained in:
93
article.ja-JP.js
Normal file
93
article.ja-JP.js
Normal file
File diff suppressed because one or more lines are too long
1315
locales/ja-JP/content.js
Normal file
1315
locales/ja-JP/content.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -150,13 +150,18 @@ function chunk(data) {
|
|||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then get the section map. This will try to load .jsx code, which will fail,
|
|
||||||
// but the above shim makes a failure simply return an empty object instead.
|
/**
|
||||||
// This is good: we only care about the keys, not the content.
|
* Process a single locale, with `en-GB` fallback for missing files.
|
||||||
var index = require("./components/sections");
|
*/
|
||||||
var sections = Object.keys(index);
|
function processLocale(locale) {
|
||||||
var content = {};
|
// Get the section map. This will try to load .jsx code, which will fail,
|
||||||
sections.forEach((cname, number) => {
|
// but the above shim makes a failure simply return an empty object instead.
|
||||||
|
// This is good: we only care about the keys, not the content.
|
||||||
|
var index = require("./components/sections");
|
||||||
|
var sections = Object.keys(index);
|
||||||
|
var content = {};
|
||||||
|
sections.forEach((cname, number) => {
|
||||||
|
|
||||||
// Grab locale file, or defaultLocale file if the chosen locale has
|
// Grab locale file, or defaultLocale file if the chosen locale has
|
||||||
// has no translated content (yet)...
|
// has no translated content (yet)...
|
||||||
@@ -203,11 +208,10 @@ sections.forEach((cname, number) => {
|
|||||||
title: title,
|
title: title,
|
||||||
getContent: "<section>" + data + "</section>"
|
getContent: "<section>" + data + "</section>"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// Now, form a JSX resource for this locale.
|
var bcode = JSON.stringify(content, false, 2);
|
||||||
var bcode = JSON.stringify(content, false, 2);
|
bcode = bcode.replace(/"<section>/g, "function(handler) { return <section>")
|
||||||
bcode = bcode.replace(/"<section>/g, "function(handler) { return <section>")
|
|
||||||
.replace(/this\.(\w)/g, "handler.$1")
|
.replace(/this\.(\w)/g, "handler.$1")
|
||||||
.replace(/<\/section>"(,?)/g, "</section>; }$1\n")
|
.replace(/<\/section>"(,?)/g, "</section>; }$1\n")
|
||||||
.replace(/\\"/g,'"')
|
.replace(/\\"/g,'"')
|
||||||
@@ -215,8 +219,22 @@ bcode = bcode.replace(/"<section>/g, "function(handler) { return <section>")
|
|||||||
.replace(/></g,'>\n<')
|
.replace(/></g,'>\n<')
|
||||||
.replace(/\\\\/g, '\\');
|
.replace(/\\\\/g, '\\');
|
||||||
|
|
||||||
var bundle = `var React = require('react');\nvar Graphic = require("../../components/Graphic.jsx");\nvar SectionHeader = require("../../components/SectionHeader.jsx");\n\nmodule.exports = ${bcode};\n`;
|
var bundle = `var React = require('react');\nvar Graphic = require("../../components/Graphic.jsx");\nvar SectionHeader = require("../../components/SectionHeader.jsx");\n\nmodule.exports = ${bcode};\n`;
|
||||||
|
|
||||||
var dir = `./locales/${locale}`;
|
var dir = `./locales/${locale}`;
|
||||||
fs.ensureDir(dir);
|
fs.ensureDir(dir);
|
||||||
fs.writeFileSync(`${dir}/content.js`, bundle);
|
fs.writeFileSync(`${dir}/content.js`, bundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all locales used
|
||||||
|
var glob = require('glob');
|
||||||
|
glob("components/sections/**/content*md", (err, files) => {
|
||||||
|
var locales = [];
|
||||||
|
files.forEach(file => {
|
||||||
|
let locale = file.match(/content\.([^.]+)\.md/)[1];
|
||||||
|
if (locales.indexOf(locale) === -1) {
|
||||||
|
locales.push(locale);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
locales.forEach( processLocale);
|
||||||
|
});
|
||||||
|
@@ -6,10 +6,10 @@
|
|||||||
"localize": "node make-locales",
|
"localize": "node make-locales",
|
||||||
"build": "npm run localize && npm run less && webpack -p",
|
"build": "npm run localize && npm run less && webpack -p",
|
||||||
"build:zh-CN": "npm run localize && npm run less && cross-env LOCALE=zh-CN webpack -p",
|
"build:zh-CN": "npm run localize && npm run less && cross-env LOCALE=zh-CN webpack -p",
|
||||||
|
"build:ja-JP": "npm run localize && npm run less && cross-env LOCALE=ja-JP webpack -p",
|
||||||
"dev": "npm run localize && npm run less && webpack-dev-server --progress --colors --hot --inline",
|
"dev": "npm run localize && npm run less && webpack-dev-server --progress --colors --hot --inline",
|
||||||
"dev:zh-CN": "npm run localize && npm run less && cross-env LOCALE=zh-CN webpack-dev-server --progress --colors --hot --inline",
|
"dev:zh-CN": "npm run localize && npm run less && cross-env LOCALE=zh-CN webpack-dev-server --progress --colors --hot --inline",
|
||||||
|
"dev:ja-JP": "npm run localize && npm run less && cross-env LOCALE=ja-JP webpack-dev-server --progress --colors --hot --inline",
|
||||||
"latex": "node tools/mathjax",
|
"latex": "node tools/mathjax",
|
||||||
"less": "lessc stylesheets/style.less > stylesheets/style.css",
|
"less": "lessc stylesheets/style.less > stylesheets/style.css",
|
||||||
"singles": "npm run dev -- --singles",
|
"singles": "npm run dev -- --singles",
|
||||||
@@ -76,5 +76,8 @@
|
|||||||
"uglify-loader": "^1.3.0",
|
"uglify-loader": "^1.3.0",
|
||||||
"webpack": "^2.0.0",
|
"webpack": "^2.0.0",
|
||||||
"webpack-dev-server": "^2.0.0"
|
"webpack-dev-server": "^2.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"glob": "^7.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user