parent
f0c12b28fd
commit
99e8710095
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/ar.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/bg.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/ca.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/de.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/eo.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/es.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/fa.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/fi.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/fr.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/he.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/hr.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/hu.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/id.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/io.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/it.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/ja.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/ko.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/nl.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/no.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/oc.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/pt-BR.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/pt.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/ru.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/sv.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/th.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/tr.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/uk.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/zh-CN.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/zh-HK.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -0,0 +1,7 @@
|
||||
import inherited from 'mastodon/locales/zh-TW.json';
|
||||
|
||||
const messages = {
|
||||
// No translations available.
|
||||
};
|
||||
|
||||
export default Object.assign({}, inherited, messages);
|
@ -1,70 +1,66 @@
|
||||
// A message from upstream:
|
||||
// ========================
|
||||
// To avoid adding a lot of boilerplate, locale packs are
|
||||
// automatically generated here. These are written into the tmp/
|
||||
// directory and then used to generate locale_en.js, locale_fr.js, etc.
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
// Glitch note:
|
||||
// ============
|
||||
// This code has been entirely rewritten to support glitch flavours.
|
||||
// However, the underlying process is exactly the same.
|
||||
|
||||
const { existsSync, readdirSync, writeFileSync } = require('fs');
|
||||
const { join, resolve } = require('path');
|
||||
const rimraf = require('rimraf');
|
||||
const mkdirp = require('mkdirp');
|
||||
const { flavours } = require('./configuration.js');
|
||||
|
||||
const localesJsonPath = path.join(__dirname, '../../app/javascript/mastodon/locales');
|
||||
const locales = fs.readdirSync(localesJsonPath).filter(filename => {
|
||||
return /\.json$/.test(filename) &&
|
||||
!/defaultMessages/.test(filename) &&
|
||||
!/whitelist/.test(filename);
|
||||
}).map(filename => filename.replace(/\.json$/, ''));
|
||||
|
||||
const outPath = path.join(__dirname, '../../tmp/packs');
|
||||
|
||||
rimraf.sync(outPath);
|
||||
mkdirp.sync(outPath);
|
||||
|
||||
const outPaths = [];
|
||||
|
||||
locales.forEach(locale => {
|
||||
const localePath = path.join(outPath, `locale_${locale}.js`);
|
||||
const baseLocale = locale.split('-')[0]; // e.g. 'zh-TW' -> 'zh'
|
||||
const localeDataPath = [
|
||||
// first try react-intl
|
||||
`../../node_modules/react-intl/locale-data/${baseLocale}.js`,
|
||||
// then check locales/locale-data
|
||||
`../../app/javascript/mastodon/locales/locale-data/${baseLocale}.js`,
|
||||
// fall back to English (this is what react-intl does anyway)
|
||||
'../../node_modules/react-intl/locale-data/en.js',
|
||||
].filter(filename => fs.existsSync(path.join(outPath, filename)))
|
||||
.map(filename => filename.replace(/..\/..\/node_modules\//, ''))[0];
|
||||
|
||||
let glitchInject = `
|
||||
const mergedMessages = messages;
|
||||
`;
|
||||
|
||||
const glitchPath = `../../app/javascript/glitch/locales/${locale}.json`;
|
||||
if (fs.existsSync(path.join(outPath, glitchPath))) {
|
||||
glitchInject = `
|
||||
import glitchMessages from ${JSON.stringify(glitchPath)};
|
||||
|
||||
let mergedMessages = messages;
|
||||
Object.keys(glitchMessages).forEach(function (key) {
|
||||
mergedMessages[key] = glitchMessages[key];
|
||||
});
|
||||
|
||||
`;
|
||||
module.exports = Object.keys(flavours).reduce(function (map, entry) {
|
||||
const flavour = flavours[entry];
|
||||
if (!flavour.locales) {
|
||||
return map;
|
||||
}
|
||||
const locales = readdirSync(flavour.locales).filter(
|
||||
filename => /\.js(?:on)?$/.test(filename) && !/defaultMessages|whitelist|index/.test(filename)
|
||||
);
|
||||
const outPath = resolve('tmp', 'locales', entry);
|
||||
|
||||
rimraf.sync(outPath);
|
||||
mkdirp.sync(outPath);
|
||||
|
||||
const localeContent = `//
|
||||
// locale_${locale}.js
|
||||
locales.forEach(function (locale) {
|
||||
const localeName = locale.replace(/\.js(?:on)?$/, '');
|
||||
const localePath = join(outPath, `${localeName}.js`);
|
||||
const baseLocale = localeName.split('-')[0]; // e.g. 'zh-TW' -> 'zh'
|
||||
const localeDataPath = [
|
||||
// first try react-intl
|
||||
`node_modules/react-intl/locale-data/${baseLocale}.js`,
|
||||
// then check locales/locale-data
|
||||
`app/javascript/locales/locale-data/${baseLocale}.js`,
|
||||
// fall back to English (this is what react-intl does anyway)
|
||||
'node_modules/react-intl/locale-data/en.js',
|
||||
].filter(
|
||||
filename => existsSync(filename)
|
||||
).map(
|
||||
filename => filename.replace(/(?:node_modules|app\/javascript)\//, '')
|
||||
)[0];
|
||||
const localeContent = `//
|
||||
// locales/${entry}/${localeName}.js
|
||||
// automatically generated by generateLocalePacks.js
|
||||
//
|
||||
import messages from '../../app/javascript/mastodon/locales/${locale}.json';
|
||||
import localeData from ${JSON.stringify(localeDataPath)};
|
||||
import { setLocale } from 'locales';
|
||||
${glitchInject}
|
||||
setLocale({messages: mergedMessages, localeData: localeData});
|
||||
`;
|
||||
fs.writeFileSync(localePath, localeContent, 'utf8');
|
||||
outPaths.push(localePath);
|
||||
});
|
||||
|
||||
module.exports = outPaths;
|
||||
import messages from '../../../${flavour.locales}/${locale.replace(/\.js$/, '')}';
|
||||
import localeData from '${localeDataPath}';
|
||||
import { setLocale } from 'locales';
|
||||
|
||||
setLocale({
|
||||
localeData,
|
||||
messages,
|
||||
});
|
||||
`;
|
||||
writeFileSync(localePath, localeContent, 'utf8');
|
||||
map[`locales/${entry}/${localeName}`] = localePath;
|
||||
});
|
||||
|
||||
return map;
|
||||
}, {});
|
||||
|
Loading…
Reference in new issue