Skip to content

Commit

Permalink
Merge pull request #75 from hideki0403/develop
Browse files Browse the repository at this point in the history
release: v1.5.1
  • Loading branch information
hideki0403 authored Jul 20, 2022
2 parents 61bec52 + 9afef5e commit d899f98
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 44 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "better-japanese",
"version": "1.5.0",
"version": "1.5.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
80 changes: 39 additions & 41 deletions src/common/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const betterJapanese = {
config: {
hash: '0',
replaceJP: true,
replaceBeautify: true,
replaceTime: true,
replaceBackgroundName: true,
replaceMarketQuote: true,
Expand All @@ -15,7 +14,7 @@ const betterJapanese = {
replaceBuildings: true,
replaceCSS: true,
replaceNews: true,
showSpoilerAlert: false,
showSpoilerAlert: true,
numberJP: true,
shortFormatJP: false,
secondFormatJP: true,
Expand Down Expand Up @@ -184,48 +183,46 @@ const betterJapanese = {
// 塵劫記用の単位
betterJapanese.formats.short = [...betterJapanese.formats.prefix, '阿僧祇', '那由多', '不可思議', '無量大数']

// 設定の「日本語訳の改善」がOFFになっている場合はここから下は実行しない (ニュース欄やアップデート履歴が壊れる)
if (!betterJapanese.config.replaceJP) return

// 設定によって日本語単位を使用するように変更、同時にカンマ区切りも場合によって変更
if (betterJapanese.config.replaceBeautify) {
// 本家の挿入関数に追加
numberFormatters = [
formatEveryThirdPower(formatShort),
formatEveryThirdPower(formatLong),
rawFormatter,
betterJapanese.formatEveryFourthPower()
]

if (!betterJapanese.origins.beautify) betterJapanese.origins.beautify = Beautify
Beautify = function(val, floats) {
let negative = (val < 0)
let decimal = ''
let fixed = val.toFixed(floats)
if (floats > 0 && Math.abs(val) < 1000 && Math.floor(fixed) != fixed) decimal = '.' + (fixed.toString()).split('.')[1]
val = Math.floor(Math.abs(val))
if (floats > 0 && fixed == val + 1) val++
let format = Game.prefs.format ? 2 : betterJapanese.config.numberJP ? 3 : 1
let formatter = numberFormatters[format]
let output = (val.toString().indexOf('e+') != -1 && format == 2) ? val.toPrecision(3).toString() : formatter(val).toString()
if (Game.prefs.format || (betterJapanese.config.numberJP && betterJapanese.config.secondFormatJP)) {
output = output.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
} else {
output = output.replace(/^(\d)(\d{3})/, '$1,$2')
}
if (output == '0') negative = false
return negative ? '-' + output : output + decimal
if (!betterJapanese.origins.beautify) betterJapanese.origins.beautify = Beautify
Beautify = function(val, floats) {
let negative = (val < 0)
let decimal = ''
let fixed = val.toFixed(floats)
if (floats > 0 && Math.abs(val) < 1000 && Math.floor(fixed) != fixed) decimal = '.' + (fixed.toString()).split('.')[1]
val = Math.floor(Math.abs(val))
if (floats > 0 && fixed == val + 1) val++
let format = Game.prefs.format ? 2 : betterJapanese.config.numberJP ? 3 : 1
let formatter = numberFormatters[format]
let output = (val.toString().indexOf('e+') != -1 && format == 2) ? val.toPrecision(3).toString() : formatter(val).toString()
if (Game.prefs.format || (betterJapanese.config.numberJP && betterJapanese.config.secondFormatJP)) {
output = output.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
} else {
output = output.replace(/^(\d)(\d{3})/, '$1,$2')
}

// 指数表記の場合表示が崩れる現象を修正
if (!betterJapanese.origins.simpleBeautify) betterJapanese.origins.simpleBeautify = SimpleBeautify
SimpleBeautify = function(val) {
if (val.toString().indexOf('e+') >= 0) {
return val.toString().replace(/(?<=.)(\d{3})(?=\d)/g, '$1,')
}
return betterJapanese.origins.simpleBeautify(val)
if (output == '0') negative = false
return negative ? '-' + output : output + decimal
}

// 本家の挿入関数に追加
numberFormatters = [
formatEveryThirdPower(formatShort),
formatEveryThirdPower(formatLong),
rawFormatter,
betterJapanese.formatEveryFourthPower()
]

// 指数表記の場合表示が崩れる現象を修正
if (!betterJapanese.origins.simpleBeautify) betterJapanese.origins.simpleBeautify = SimpleBeautify
SimpleBeautify = function(val) {
if (val.toString().indexOf('e+') >= 0) {
return val.toString().replace(/(?<=.)(\d{3})(?=\d)/g, '$1,')
}
return betterJapanese.origins.simpleBeautify(val)
}

// 設定の「日本語訳の改善」がOFFになっている場合はここから下は実行しない (ニュース欄やアップデート履歴が壊れる)
if (!betterJapanese.config.replaceJP) return

// 時間表記からカンマを取り除く
if (betterJapanese.config.replaceTime) {
Expand Down Expand Up @@ -567,6 +564,7 @@ const betterJapanese = {
Game.Prompt(`
<h3>非公式日本語訳 詳細設定</h3>
<div>ゲームの処理を変更している翻訳処理について利用するか設定できます。<br>バグがあった場合、これらの翻訳はゲーム内容に影響を及ぼす可能性があります。</div>
${!betterJapanese.config.replaceJP ? '<div class="line"></div><p style="color: red; font-weight: bold;">「日本語訳の改善」がオフのため、下記の設定はすべてオフとして処理されます。</p>' : ''}
<div class="line"></div>
<div class="listing" style="width: 100%; text-align: left; padding: 0px 10px;">
<div id="dummyIgnoreListJP"></div>
Expand All @@ -577,9 +575,9 @@ const betterJapanese = {
<div id="dummySettingJP"></div>
</div>
`, ['閉じる'], null, 'settingsList')

betterJapanese.writeButton('openIgnoreWordList', null, '置き換え除外リスト', '非公式翻訳に置き換えたくない単語を指定することができます。', betterJapanese.openIgnorePrompt, 'dummyIgnoreListJP')
betterJapanese.writeButton('toggleShowSpoilerAlertButton', 'showSpoilerAlert', '除外リスト表示確認', '除外リストを表示する際にネタバレに対する確認を表示します。', null, 'dummyIgnoreListJP')
betterJapanese.writeButton('toggleReplaceBeautifyButton', 'replaceBeautify', '日本語単位の使用', '日本語単位を使用できるようにします。無効化した場合は「日本語単位」の設定および付随する設定が機能しなくなります。', null, 'dummySettingJP')
betterJapanese.writeButton('toggleReplaceBackgroundNameButton', 'replaceBackgroundName', '背景名', '背景の名前を翻訳します。', null, 'dummySettingJP')
betterJapanese.writeButton('toggleReplaceMarketQuoteButton', 'replaceMarketQuote', '在庫市場のフレーバーテキスト', '在庫市場のフレーバーテキストを翻訳し、日本語で表示されるようにします。', null, 'dummySettingJP')
betterJapanese.writeButton('toggleReplaceGardenImageButton', 'replaceGardenImage', '菜園情報の画像', '菜園情報内で表示される画像を日本語のものに置き換えます。', null, 'dummySettingJP')
Expand Down

0 comments on commit d899f98

Please sign in to comment.