ローカライズデータ
このゲームのローカライズデータは sharedassets1.assets の 80days.inkcontent にあります。
文字コードは UTF-8N で JSON 形式です。
この 80days.inkcontent には画面に表示される文字列以外に制御文も含まれます。
よくある紙芝居アドベンチャーゲームのスクリプトみたいなものです。

上画像の部分をローカライズします。80days.inkcontent に上記の文章が含まれている部分があるのでそこを日本語にします。文字コードは UTF-8N です。

入れ替えて同じ画面なんですが表示されません。
output_log を見てみると以下のエラーが出ています。
JsonReaderException: Unterminated string. Expected delimiter: ". Line 1, position 4960.
at Newtonsoft.Json.JsonTextReader.ReadStringIntoBuffer (Char quote) [0x00000] in <filename unknown>:0
・
・
at Newtonsoft.Json.JsonTextReader.ParseString (Char quote) [0x00000] in <filename unknown>:0
at Inklewriter.Knot.StitchNamed (System.String stitchName) [0x00000] in <filename unknown>:0
at Inklewriter.Knot.StitchWithPath (System.String path) [0x00000] in <filename unknown>:0
at Inklewriter.Story.FindStitch (System.String stitchPath, System.String parentPath) [0x00000] in <filename unknown>:0
at Inklewriter.StoryChunk.FindStitch (System.String stitchPath) [0x00000] in <filename unknown>:0
ライブラリの問題なのかJSONデータ側の問題なのかと思い、ローカライズした部分の JSON をライブラリでパースして見ます。正常に動作します。ライブラリでは無いので
at Inklewriter.Knot.StitchNamed (System.String stitchName) [0x00000] in <filename unknown>:0
ここに注目して Inklewriter.Knot を調べます。Assembly-CSharp.dll をデコンパイルします。
public BaseStitch StitchNamed(string stitchName) を見ます。
text = (obj as string);
string[] array = text.Split(new char[] { ' ' });
int index = Convert.ToInt32(array[0]);
int count = Convert.ToInt32(array[1]);
UTF8Encoding uTF8Encoding = new UTF8Encoding();
string @string = uTF8Encoding.GetString(this.indexedContentText.bytes, index, count);
object definition = Utils.JSON.ToObject(Utils.JSON.Deserialise(@string));
怪しいのはuTF8Encoding.GetString() ですね。ここで正常な JSON データを切り取っていないのでライブラリに渡した後でエラーになっているようです。ではこの index, count はどこで設定されているのかを見ます。
設定されているのは
private void CommonInit(Dictionary<string, object> knotDictionary, TextAsset indexedContentText)
Dictionary<string, object> dictionary = knotDictionary["indexed-content"] as Dictionary<string, object>;
this.indexedStitchRanges = (dictionary["ranges"] as Dictionary<string, object>);
ここです。注目すべきは "indexed-content", "ranges" です。この値を検索します。
sharedassets1.assets の 80days (これもJSON)に
"indexed-content":
{
"filename":"80days.inkcontent",
"ranges":
{
"storycrashed":"0 150",
"repeat_visit_bank":"150 1294",
"village_bank":"1444 97",
"medium_bank":"1541 97",
このような部分があります。"0 150" のようにオフセットとサイズがここに指定してあります。
ローカライズによりここのオフセットとサイズがずれたため正常に JSON データが切り出せていなかったようです。
ここを修正すると

正常に表示されました。(相変わらず機械翻訳でひどい訳ですが)
結論:
翻訳データは 80days.inkcontent にあるんですがその修正だけでは駄目
80days のオフセットとサイズも修正する必要がある。
オフセットとサイズの修正は手作業ではかなりの量があるのでプログラム実装した方が良いでしょう。
80days.inkcontent の1行辺りの UTF-8 のバイト数を計算(サイズ)
サイズを足しこんでいくのがオフセットそれを 80days の JSON で indexed-content, range の部分を置き換える感じです。
このゲームのローカライズデータは sharedassets1.assets の 80days.inkcontent にあります。
文字コードは UTF-8N で JSON 形式です。
この 80days.inkcontent には画面に表示される文字列以外に制御文も含まれます。
よくある紙芝居アドベンチャーゲームのスクリプトみたいなものです。

上画像の部分をローカライズします。80days.inkcontent に上記の文章が含まれている部分があるのでそこを日本語にします。文字コードは UTF-8N です。

入れ替えて同じ画面なんですが表示されません。
output_log を見てみると以下のエラーが出ています。
JsonReaderException: Unterminated string. Expected delimiter: ". Line 1, position 4960.
at Newtonsoft.Json.JsonTextReader.ReadStringIntoBuffer (Char quote) [0x00000] in <filename unknown>:0
・
・
at Newtonsoft.Json.JsonTextReader.ParseString (Char quote) [0x00000] in <filename unknown>:0
at Inklewriter.Knot.StitchNamed (System.String stitchName) [0x00000] in <filename unknown>:0
at Inklewriter.Knot.StitchWithPath (System.String path) [0x00000] in <filename unknown>:0
at Inklewriter.Story.FindStitch (System.String stitchPath, System.String parentPath) [0x00000] in <filename unknown>:0
at Inklewriter.StoryChunk.FindStitch (System.String stitchPath) [0x00000] in <filename unknown>:0
ライブラリの問題なのかJSONデータ側の問題なのかと思い、ローカライズした部分の JSON をライブラリでパースして見ます。正常に動作します。ライブラリでは無いので
at Inklewriter.Knot.StitchNamed (System.String stitchName) [0x00000] in <filename unknown>:0
ここに注目して Inklewriter.Knot を調べます。Assembly-CSharp.dll をデコンパイルします。
public BaseStitch StitchNamed(string stitchName) を見ます。
text = (obj as string);
string[] array = text.Split(new char[] { ' ' });
int index = Convert.ToInt32(array[0]);
int count = Convert.ToInt32(array[1]);
UTF8Encoding uTF8Encoding = new UTF8Encoding();
string @string = uTF8Encoding.GetString(this.indexedContentText.bytes, index, count);
object definition = Utils.JSON.ToObject(Utils.JSON.Deserialise(@string));
怪しいのはuTF8Encoding.GetString() ですね。ここで正常な JSON データを切り取っていないのでライブラリに渡した後でエラーになっているようです。ではこの index, count はどこで設定されているのかを見ます。
設定されているのは
private void CommonInit(Dictionary<string, object> knotDictionary, TextAsset indexedContentText)
Dictionary<string, object> dictionary = knotDictionary["indexed-content"] as Dictionary<string, object>;
this.indexedStitchRanges = (dictionary["ranges"] as Dictionary<string, object>);
ここです。注目すべきは "indexed-content", "ranges" です。この値を検索します。
sharedassets1.assets の 80days (これもJSON)に
"indexed-content":
{
"filename":"80days.inkcontent",
"ranges":
{
"storycrashed":"0 150",
"repeat_visit_bank":"150 1294",
"village_bank":"1444 97",
"medium_bank":"1541 97",
このような部分があります。"0 150" のようにオフセットとサイズがここに指定してあります。
ローカライズによりここのオフセットとサイズがずれたため正常に JSON データが切り出せていなかったようです。
ここを修正すると

正常に表示されました。(相変わらず機械翻訳でひどい訳ですが)
結論:
翻訳データは 80days.inkcontent にあるんですがその修正だけでは駄目
80days のオフセットとサイズも修正する必要がある。
オフセットとサイズの修正は手作業ではかなりの量があるのでプログラム実装した方が良いでしょう。
80days.inkcontent の1行辺りの UTF-8 のバイト数を計算(サイズ)
サイズを足しこんでいくのがオフセットそれを 80days の JSON で indexed-content, range の部分を置き換える感じです。
コメント