Harvest-Festival日本語化支援ツール
by MKGaru
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/6.1.19/browser.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.20.0/polyfill.min.js"></script>
<a id="download" href="#" download="ja_JP.lang">読み込み中</a>
<textarea id="tmp">必要な言語ファイル等を読み込み中です。</textarea>
CSS
html,body{
height:100%;
margin:0;
padding:0;
}
textarea{
width:98%;
height:calc(98% - 1.5em);
resize:none;
}
Babel + JSX
const sheetURL = `https://content-sheets.googleapis.com/v4/spreadsheets/1VF20wdBM5rR5oKGKqWrAP5yFBVNQ3kI_wbc71YoYejM`;
async function main(){
const engOrder = [];
const engLocale = new Map();
const jpyLocale = new Map();
await Promise.all([
fetch(`${sheetURL}/values/シート1!A8:B2000?key=AIzaSyDMZ992n-d1_Xw_kJQJQ1XYJmkERH_wLII`)
.then(res=>res.json())
.then(res=>res.values
.forEach(words=>{
if(words.length<2) return;
let m = words[0].match(/([^=]*)=(.*)/);
jpyLocale.set(m?m[1]:words[0],words[1].split('\n')[0]);
})
),
fetch('https://raw.githubusercontent.com/PenguinSquad/Harvest-Festival/1.10.2-0.5.X/src/main/resources/assets/harvestfestival/lang/en_US.lang')
.then(res=>res.text())
.then(text=>text
.split('\n')
.map(line=>{let m=line.match(/([^=]*)=(.*)/);engOrder.push(m?m[1]:line);return m})
.filter(words=>words)
.map(words=>words.splice(1,2))
.forEach(words=>{
if(words.length<2) return;
engLocale.set(words[0],words[1])
})
)
])
let lines = engOrder.map(key=>jpyLocale.has(key)
? `${key}=${jpyLocale.get(key)}`
: engLocale.has(key)
?`${key}=${engLocale.get(key)}`
: key
)
let result = lines.join('\r\n');
tmp.value = result;
download.href= URL.createObjectURL(new Blob([ result ], { "type" : "text/plain" }));
download.innerText = 'ダウンロード: ja_JP.lang';
}
main();
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-25446362-3', 'auto');
ga('send', 'pageview');