Skip to content

Commit

Permalink
Merge pull request #68 from hideki0403/develop
Browse files Browse the repository at this point in the history
release: v1.4.8
  • Loading branch information
hideki0403 authored Jul 16, 2022
2 parents 3c863e3 + 28ac080 commit 8c805a7
Show file tree
Hide file tree
Showing 10 changed files with 292 additions and 78 deletions.
16 changes: 9 additions & 7 deletions locales/ja.json5
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@
"You will keep your achievements, building levels and sugar lumps.": "実績と施設レベル、角砂糖は引き継がれます。",
"Ascending": "昇天中",
"So long, cookies.": "クッキーたち、またね。",
"You forfeit your %1.": "貯蓄していた %1クッキー を失いました。",
"You forfeit your %1.": "貯蓄していた %1 を失いました。",
"Prestige level:": "名声レベル :",
"Heavenly chips:": "ヘブンリーチップス :",
"%1 prestige level": [
Expand Down Expand Up @@ -3558,7 +3558,7 @@
"Cryogenically preserve your garden.<br>Plants no longer grow, spread or die; they provide no benefits.<br>Soil cannot be changed.<div class=\"line\"></div>Using this will effectively pause your garden.": "菜園を極低温で状態維持する。<br>全作物の成長が止まり、拡散や枯死も起こらず、効果も発揮しない。<br>土壌変更も出来ない。<div class=\"line\"></div>使用することで菜園を効果的に保存することが出来る。",
"Garden is frozen. Unfreeze to resume.": "菜園を冷凍しています。解凍するには再度押してください。",
"Sacrifice garden": "生贄の畑",
"A swarm of sugar hornets comes down on your garden, <span class=\"red\">destroying every plant as well as every seed you've unlocked</span> - leaving only a %1 seed.<br>In exchange, they will grant you <span class=\"green\">%2</span>.<br>This action is only available with a complete seed log.": "砂糖蜂の群れが菜園にやって来る、<span class=\"red\">開放したほぼすべての種が破壊される</span> - %1のみ残る。<br>引き換えに、 <span class=\"green\">%2</span> が与えられる。<br>この動作は品種記録が完成しているときにのみ利用可能。",
"A swarm of sugar hornets comes down on your garden, <span class=\"red\">destroying every plant as well as every seed you've unlocked</span> - leaving only a %1 seed.<br>In exchange, they will grant you <span class=\"green\">%2</span>.<br>This action is only available with a complete seed log.": "砂糖蜂の群れが菜園にやって来て、<span class=\"red\">開放したほぼすべての種が破壊される</span> - %1のみ残る。<br>引き換えに、 <span class=\"green\">%2</span> が与えられる。<br>この動作は品種記録が完成しているときにのみ利用可能。",
"Do you REALLY want to sacrifice your garden to the sugar hornets?<br><small>You will be left with an empty plot and only the %1 seed unlocked.<br>In return, you will gain <b>%2 sugar lumps</b>.</small>": "あなたは 本 当 に 砂糖蜂に庭園を捧げたいのですか?<br><small>まっさらになった庭園と%1の種子だけが解除された状態となります。<br>その対価として、 <b>%2角砂糖</b> を手に入れます。",
"Sacrifice!": "生贄に!",
"You've sacrificed your garden to the sugar hornets, destroying your crops and your knowledge of seeds.<br>In the remains, you find <b>%1 sugar lumps</b>.": "菜園を砂糖蜂の生贄にし、作物と種に関する知識を破壊されました。<br>残骸の中に、 <b>%1角砂糖</b> 見つけました。",
Expand Down Expand Up @@ -3788,7 +3788,7 @@

"#CATEGORY: フレーバーテキスト/在庫市場": "「在庫市場」のフレーバーテキスト",

"Buy that vintage car you've always wanted. Just pay us back.": "いつも欲しがってたヴィンテージの車を購入しよう。とにかく金を返してもらうんだ。",
"Buy that vintage car you've always wanted. Just pay us back.": "いつも欲しがってたヴィンテージの車を購入しよう。返済はしっかりとしろ。",
"Bad credit? No problem. It's your money, and you need it now.": "良くない信用取引だって?問題ない。それは元々あなたの金であり、今あなたが求めるものだ。",
"Finance your next house, boat, spouse, etc. You've earned it.": "次の家やボート、配偶者、その他もろもろを融通してもらえ。それらはあなたが稼いできたものだ。",

Expand Down Expand Up @@ -3849,9 +3849,9 @@
"#CATEGORY: ミニゲーム/神殿/UI": "ミニゲーム「神殿」のUI部分の翻訳",

"Pantheon": "神殿",
"Diamond slot": "ダイアモンド",
"Ruby slot": "ルビー",
"Jade slot": "翡翠",
"Diamond slot": "ダイアモンドのスロット",
"Ruby slot": "ルビーのスロット",
"Jade slot": "翡翠のスロット",
"empty": "空き",
"Release to assign %1 to this slot.": "このスロットに %1 を配置するには、ドロップしてください。",
"Drag a spirit onto this slot to assign it.": "聖霊を配置するには、聖霊をこのスロットの上にドラッグしてください。",
Expand Down Expand Up @@ -5638,5 +5638,7 @@
"check out our %1 with rad cookie shirts, hoodies and stickers": "イカすクッキーシャツやパーカー、ステッカーがある%1をチェック",
"Shop": "ショップ",
"disable your adblocker (if you want!)": "アドブロッカーの無効化(お任せするよ!)",
"refill": "回復"
"refill": "回復",
"Reincarnated": "転生しました",
"DOUGH JONES INDEX": "ドウ平均株価"
}
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.4.7",
"version": "1.4.8",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
99 changes: 63 additions & 36 deletions src/common/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
const betterJapanese = {
name: 'betterJapanese',
version: null,
config: {
hash: '0',
replaceJP: true,
replaceNews: true,
numberJP: true,
shortFormatJP: false,
secondFormatJP: true,
ignoreList: []
},
api: {
url: {
release: 'https://pages.yukineko.me/better-japanese/api/release.json',
Expand All @@ -11,15 +21,6 @@ const betterJapanese = {
},
cache: null
},
config: {
hash: '0',
replaceJP: true,
replaceNews: true,
numberJP: true,
shortFormatJP: false,
secondFormatJP: true,
ignoreList: []
},
isDev: false,
initialized: false,
fallbackTimer: 0,
Expand All @@ -35,6 +36,11 @@ const betterJapanese = {
isRegisteredHook: false,

init: function() {
let versionPath = App ? `file:///${App.mods['BetterJapanese'].dir.replace(/\\/g, '/')}/version.json` : 'https://pages.yukineko.me/better-japanese/version.json'
this.getJSON(versionPath).then(res => {
res ? this.version = res.version : this.version = '0.0.0'
})

this.fallbackTimer = setTimeout(() => {
this.checkUpdate()
this.initialized = true
Expand All @@ -45,7 +51,7 @@ const betterJapanese = {
if (!this.isRegisteredHook) this.initAfterLoad()

// Web版で既にDOMが構築されていた場合はDOMを再構成するスクリプトを読み込む (一部の翻訳が適用されないため)
if (!App && Game.ready) Game.LoadMod('https://pages.yukineko.me/better-japanese/rebuild.js')
if (!App && Game.ready) Game.LoadMod(`https://pages.yukineko.me/better-japanese/rebuild.js?nocache=${Date.now()}`)

this.log('Initialized')
},
Expand All @@ -55,20 +61,21 @@ const betterJapanese = {

// メニューに独自ボタンを実装
// この方法で実装しないとCCSEなどのメニュー独自実装Modと競合してしまう
let origin = eval('Game.UpdateMenu.toString()').split('\n')
let origin = Game.UpdateMenu.toString().split('\n')
origin.splice(origin.length - 1, 0, `
if (Game.onMenu == 'prefs') {
betterJapanese.injectMenu()
}
if (Game.onMenu == 'stats') {
betterJapanese.fixStats()
betterJapanese.injectStats()
}
`)
eval(`Game.UpdateMenu = ${origin.join('\n')}`)
Function(`Game.UpdateMenu = ${origin.join('\n')}`)()

// 時間表記からカンマを取り除く
betterJapanese.origins.sayTime = Game.sayTime
if (!betterJapanese.origins.sayTime) betterJapanese.origins.sayTime = Game.sayTime
Game.sayTime = function(time, detail) {
return betterJapanese.origins.sayTime(time, detail).replaceAll(', ', '')
}
Expand All @@ -95,7 +102,7 @@ const betterJapanese = {
]

// 設定によって日本語単位を使用するように変更、同時にカンマ区切りも場合によって変更
betterJapanese.origins.beautify = Beautify
if (!betterJapanese.origins.beautify) betterJapanese.origins.beautify = Beautify
Beautify = function(val, floats) {
let negative = (val < 0)
let decimal = ''
Expand All @@ -115,6 +122,15 @@ const betterJapanese = {
return negative ? '-' + output : output + decimal
}

// 指数表記の場合表示が崩れる現象を修正
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)
}

// カスタムCSSを適用
let customStyle = document.createElement('style')
customStyle.innerHTML = `
Expand Down Expand Up @@ -194,9 +210,7 @@ const betterJapanese = {

// 在庫市場のquoteを実装
while (!Game.Objects['Bank'].hasOwnProperty('minigame')) await new Promise(resolve => setTimeout(resolve, 1000))
if (typeof (betterJapanese.origins.goodTooltip) === 'undefined') {
betterJapanese.origins.goodTooltip = Game.Objects['Bank'].minigame.goodTooltip
}
if (!betterJapanese.origins.goodTooltip) betterJapanese.origins.goodTooltip = Game.Objects['Bank'].minigame.goodTooltip
Game.Objects['Bank'].minigame.goodTooltip = function(id) {
return function() {
let desc = betterJapanese.origins.goodTooltip(id)()
Expand All @@ -206,8 +220,13 @@ const betterJapanese = {
}
}

// 菜園情報の画像を差し替え
while (!Game.Objects['Farm'].hasOwnProperty('minigame')) await new Promise(resolve => setTimeout(resolve, 1000))
if (!betterJapanese.origins.toolInfoDescFunc) betterJapanese.origins.toolInfoDescFunc = Game.Objects['Farm'].minigame.tools['info'].descFunc
Function('Game.Objects[\'Farm\'].minigame.tools[\'info\'].descFunc=' + Game.Objects['Farm'].minigame.tools['info'].descFunc.toString().replace('img/gardenTip.png', 'https://pages.yukineko.me/better-japanese/assets/gardenTip.png'))()

// 情報欄の翻訳
betterJapanese.origins.updateLog = Game.updateLog
if (!betterJapanese.origins.updateLog) betterJapanese.origins.updateLog = Game.updateLog
Game.updateLog = `
<div class="selectable">
<div class="section">${loc('Info')}</div>
Expand Down Expand Up @@ -280,7 +299,7 @@ const betterJapanese = {
// 巡り続ける読本のフレーバーテキスト翻訳、thisを使うので非ラムダ式(以降同様)
let upgrade = Game.Upgrades['Endless book of prose']
upgrade.desc = loc('%1 are <b>twice</b> as efficient.', cap(upgrade.buildingTie1.plural))
upgrade.originDescFunc = upgrade.descFunc
if(!upgrade.originDescFunc) upgrade.originDescFunc = upgrade.descFunc
upgrade.descFunc = function() {
let str = loc(FindLocStringByPart(`Upgrade quote ${this.id}`), Game.bakeryName)
let n = 26
Expand Down Expand Up @@ -346,7 +365,7 @@ const betterJapanese = {
Game.Upgrades['Golden switch [on]'].descFunc = func

// 猫の場合「購入済み」タグが変化することを翻訳にも反映
betterJapanese.origins.crateTooltip = Game.crateTooltip
if (!betterJapanese.origins.crateTooltip) betterJapanese.origins.crateTooltip = Game.crateTooltip
Game.crateTooltip = function(me, context) {
let tooltipText = betterJapanese.origins.crateTooltip(me, context)
if (Game.sesame) {
Expand All @@ -355,16 +374,13 @@ const betterJapanese = {
if (me.type == 'upgrade' && me.bought > 0 && me.pool != 'tech' && me.kitten) {
return tooltipText.replace(`<div class="tag" style="background-color:#fff;">${loc('Purchased')}</div>`, `<div class="tag" style="background-color:#fff;">${loc('[Tag]Purrchased')}</div>`)
}

return tooltipText
}

// 英語以外でも施設固有の生産方法をツールチップに表示
for (let i in Game.Objects) {
let obj = Game.Objects[i]
if (typeof (betterJapanese.origins.tooltip) === 'undefined') {
betterJapanese.origins.tooltip = obj.tooltip
}
if (!betterJapanese.origins.tooltip) betterJapanese.origins.tooltip = obj.tooltip
obj.actionNameJP = loc(obj.actionName)
obj.tooltip = function() {
const strDivDescriptionBlock = '<div class="descriptionBlock">'
Expand All @@ -381,9 +397,7 @@ const betterJapanese = {
// 英語以外でも施設固有の角砂糖によるレベルアップの恩恵を表示
for (let i in Game.Objects) {
let obj = Game.Objects[i]
if (typeof (betterJapanese.origins.levelTooltip) === 'undefined') {
betterJapanese.origins.levelTooltip = obj.levelTooltip
}
if (betterJapanese.origins.levelTooltip) betterJapanese.origins.levelTooltip = obj.levelTooltip
obj.levelTooltip = function() {
const strDivLine = '<div class="line"></div>'
let defaultTooltip = betterJapanese.origins.levelTooltip.bind(this)().split(strDivLine)
Expand All @@ -392,7 +406,7 @@ const betterJapanese = {
}
}

betterJapanese.origins.parseLoc = parseLoc
if (!betterJapanese.origins.parseLoc) betterJapanese.origins.parseLoc = parseLoc
parseLoc = function(str, params) {
// 独自実装されている翻訳でコケないように修正
if (str.constructor === Object) return ''
Expand All @@ -406,11 +420,11 @@ const betterJapanese = {
// ニュース欄の改善を有効化していれば置き換え
if (betterJapanese.config.replaceNews) {
// ニュースのフォーチュンクッキーの表示が壊れる問題を修正
let tickerOrigin = eval('Game.getNewTicker.toString()').replace('me.name.indexOf(\'#\')', 'me.dname.indexOf(\'No.\')').replace(/me\.baseDesc/g, 'me.ddesc')
eval(`Game.getNewTicker = ${tickerOrigin}`)
let tickerOrigin = Game.getNewTicker.toString().replace('me.name.indexOf(\'#\')', 'me.dname.indexOf(\'No.\')').replace(/me\.baseDesc/g, 'me.ddesc')
Function(`Game.getNewTicker = ${tickerOrigin}`)()

// ニュースを英語で出力させるように
betterJapanese.origins.getNewTicker = Game.getNewTicker
if (!betterJapanese.origins.getNewTicker) betterJapanese.origins.getNewTicker = Game.getNewTicker
Game.getNewTicker = function(manual) {
let isDefaultEN = EN
EN = true
Expand All @@ -419,21 +433,25 @@ const betterJapanese = {
}

// ニュースの文章を翻訳
betterJapanese.origins.tickerDraw = Game.TickerDraw
if (!betterJapanese.origins.tickerDraw) betterJapanese.origins.tickerDraw = Game.TickerDraw
Game.TickerDraw = function() {
Game.Ticker = betterJapanese.locTicker(Game.Ticker)
betterJapanese.origins.tickerDraw()
}
}

// ミニゲームでの砂糖使用時に表示する確認ツールチップを翻訳
betterJapanese.origins.refillLump = Game.refillLump
eval('Game.refillLump=' + Game.refillLump.toString().replace('\'refill\'', 'loc(\'refill\')'))
if (!betterJapanese.origins.refillLump) betterJapanese.origins.refillLump = Game.refillLump
Function('Game.refillLump = ' + Game.refillLump.toString().replace('\'refill\'', 'loc(\'refill\')'))()

// イースターのエッグ解放時に表示するツールチップのアップグレード名を翻訳
betterJapanese.origins.dropEgg = Game.DropEgg
eval('Game.DropEgg=' + Game.DropEgg.toString().replace(/(Game\.Notify\(loc\("You found an egg\!"\),'\<b\>'\+)drop(\+'\<\/b\>',Game\.Upgrades\[drop\]\.icon\);)/, '$1Game.Upgrades[drop].dname$2'))
if (!betterJapanese.origins.dropEgg) betterJapanese.origins.dropEgg = Game.DropEgg
Function('Game.DropEgg = ' + Game.DropEgg.toString().replace(/(Game\.Notify\(loc\("You found an egg\!"\),'\<b\>'\+)drop(\+'\<\/b\>',Game\.Upgrades\[drop\]\.icon\);)/, '$1Game.Upgrades[drop].dname$2'))()

// 転生後に表示されるツールチップを翻訳
if (!betterJapanese.origins.reincarnate) betterJapanese.origins.reincarnate = Game.Reincarnate
Function('Game.Reincarnate = ' + Game.Reincarnate.toString().replace(/(Game\.Notify\()'Reincarnated'(,loc\("Hello, cookies!"\),\[10,0\],4\);)/, '$1loc("Reincarnated")$2'))()

// hookを削除
Game.removeHook('create', betterJapanese.initAfterLoad)
},
Expand Down Expand Up @@ -478,6 +496,15 @@ const betterJapanese = {
this.writeButton('toggleSecondFormatJPButton', 'secondFormatJP', '第二単位', `${loc('ON')}の場合はXXXX億YYYY万、${loc('OFF')}の場合はXXXX.YYYY億のように表示されます。`, updateAll)
},

injectStats: function() {
let target = l('statsGeneral')
let div = document.createElement('div')
div.innerHTML = `<b>日本語訳改善Mod:</b> ${betterJapanese.version}`
div.className = 'listing'

if (target) target.parentNode.appendChild(div)
},

fixStats: function() {
const strLegacyStarted = '<div class="listing"><b>' + loc('Legacy started:') + '</b>'
l('menu').innerHTML = l('menu').innerHTML.replace(new RegExp(strLegacyStarted + ' (.+?), (.+?)</div>'), strLegacyStarted + ' $1、$2</div>')
Expand Down
Binary file added src/web/assets/gardenTip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/web/mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if (language && conf.replaceJP) {
ModLanguage('JA', JSON.parse(language))
}

Game.LoadMod(`https://pages.yukineko.me/better-japanese/assets/main.js?v=${Game.version}`)
Game.LoadMod(`https://pages.yukineko.me/better-japanese/assets/main.js?nocache=${Date.now()}`)
Loading

0 comments on commit 8c805a7

Please sign in to comment.