1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-29 11:10:38 +02:00

?locale=ja-JP

This commit is contained in:
Pomax
2017-02-17 11:43:11 -08:00
parent be5303545a
commit 17662007d7
4 changed files with 1492 additions and 63 deletions

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

File diff suppressed because it is too large Load Diff

View File

@@ -150,7 +150,12 @@ function chunk(data) {
return chunks; return chunks;
} }
// Then get the section map. This will try to load .jsx code, which will fail,
/**
* Process a single locale, with `en-GB` fallback for missing files.
*/
function processLocale(locale) {
// 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. // 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. // This is good: we only care about the keys, not the content.
var index = require("./components/sections"); var index = require("./components/sections");
@@ -205,7 +210,6 @@ sections.forEach((cname, number) => {
}; };
}); });
// 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")
@@ -220,3 +224,17 @@ var bundle = `var React = require('react');\nvar Graphic = require("../../compon
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);
});

View File

@@ -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"
} }
} }