mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-03 23:14:13 +00:00 
			
		
		
		
	✌️
This commit is contained in:
		
							parent
							
								
									d3b3a7fc4e
								
							
						
					
					
						commit
						a53746e9d0
					
				
					 4 changed files with 12 additions and 9 deletions
				
			
		| 
						 | 
					@ -63,6 +63,8 @@ export default class Replacer {
 | 
				
			||||||
			key = key.substr(1);
 | 
								key = key.substr(1);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (ctx && ctx.lang) this.lang = ctx.lang;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (match[0] == '"') {
 | 
							if (match[0] == '"') {
 | 
				
			||||||
			return '"' + this.get(name, key).replace(/"/g, '\\"') + '"';
 | 
								return '"' + this.get(name, key).replace(/"/g, '\\"') + '"';
 | 
				
			||||||
		} else if (match[0] == "'") {
 | 
							} else if (match[0] == "'") {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,11 +31,9 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Detect the user language
 | 
						// Detect the user language
 | 
				
			||||||
	// Note: The default language is Japanese
 | 
						// Note: The default language is Japanese
 | 
				
			||||||
	//let lang = navigator.language.split('-')[0];
 | 
						let lang = navigator.language.split('-')[0];
 | 
				
			||||||
	//if (!/^(en|ja)$/.test(lang)) lang = 'ja';
 | 
						if (!/^(en|ja)$/.test(lang)) lang = 'ja';
 | 
				
			||||||
	//if (localStorage.getItem('lang')) lang = localStorage.getItem('lang');
 | 
						if (localStorage.getItem('lang')) lang = localStorage.getItem('lang');
 | 
				
			||||||
	//if (ENV != 'production') lang = 'ja';
 | 
					 | 
				
			||||||
	const lang = 'ja';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Detect the user agent
 | 
						// Detect the user agent
 | 
				
			||||||
	const ua = navigator.userAgent.toLowerCase();
 | 
						const ua = navigator.userAgent.toLowerCase();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ const langs = Object.keys(locales);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const entries = process.env.NODE_ENV == 'production'
 | 
					const entries = process.env.NODE_ENV == 'production'
 | 
				
			||||||
	? langs.map(l => [l, false]).concat(langs.map(l => [l, true]))
 | 
						? langs.map(l => [l, false]).concat(langs.map(l => [l, true]))
 | 
				
			||||||
	: [['ja', false]];
 | 
						: langs.map(l => [l, false]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = entries.map(x => {
 | 
					module.exports = entries.map(x => {
 | 
				
			||||||
	const [lang, isProduction] = x;
 | 
						const [lang, isProduction] = x;
 | 
				
			||||||
| 
						 | 
					@ -144,7 +144,8 @@ module.exports = entries.map(x => {
 | 
				
			||||||
					query: {
 | 
										query: {
 | 
				
			||||||
						search: i18nReplacer.pattern.toString(),
 | 
											search: i18nReplacer.pattern.toString(),
 | 
				
			||||||
						replace: 'i18nReplacement',
 | 
											replace: 'i18nReplacement',
 | 
				
			||||||
						i18n: true
 | 
											i18n: true,
 | 
				
			||||||
 | 
											lang
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}, {
 | 
									}, {
 | 
				
			||||||
					loader: 'replace',
 | 
										loader: 'replace',
 | 
				
			||||||
| 
						 | 
					@ -216,7 +217,8 @@ module.exports = entries.map(x => {
 | 
				
			||||||
					query: {
 | 
										query: {
 | 
				
			||||||
						search: i18nReplacer.pattern.toString(),
 | 
											search: i18nReplacer.pattern.toString(),
 | 
				
			||||||
						replace: 'i18nReplacement',
 | 
											replace: 'i18nReplacement',
 | 
				
			||||||
						i18n: true
 | 
											i18n: true,
 | 
				
			||||||
 | 
											lang
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}, {
 | 
									}, {
 | 
				
			||||||
					loader: 'replace',
 | 
										loader: 'replace',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,8 @@ module.exports = function(src) {
 | 
				
			||||||
	const g = search[search.length - 1] == 'g';
 | 
						const g = search[search.length - 1] == 'g';
 | 
				
			||||||
	const file = this.resourcePath.replace(/\\/g, '/');
 | 
						const file = this.resourcePath.replace(/\\/g, '/');
 | 
				
			||||||
	const replace = options.i18n ? global[options.replace].bind(null, {
 | 
						const replace = options.i18n ? global[options.replace].bind(null, {
 | 
				
			||||||
		src: file
 | 
							src: file,
 | 
				
			||||||
 | 
							lang: options.lang
 | 
				
			||||||
	}) : global[options.replace];
 | 
						}) : global[options.replace];
 | 
				
			||||||
	if (typeof search != 'string' || search.length == 0) console.error('invalid search');
 | 
						if (typeof search != 'string' || search.length == 0) console.error('invalid search');
 | 
				
			||||||
	if (typeof replace != 'function') console.error('invalid replacer:', replace, this.request);
 | 
						if (typeof replace != 'function') console.error('invalid replacer:', replace, this.request);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue