mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-02-23 15:38:29 +01:00
Updated translation MO-file parser to read the MO filename from strings.xml.
This commit is contained in:
@@ -557,5 +557,10 @@
|
||||
<string name="preferences_dialog_overwrite_savegame_title">Bestätige das Überschreiben von Spielständen</string>
|
||||
<string name="preferences_dialog_overwrite_savegame">Zeigt eine Frage an ob beim Speichern auf einen bereits existierenden Spielstand dieser überschrieben werden soll.</string>
|
||||
|
||||
|
||||
<!-- =========================================== -->
|
||||
<!-- Added in v0.7.0 -->
|
||||
|
||||
<string name="localize_resources_from_mo_filename">de.mo</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -485,4 +485,8 @@
|
||||
<string name="actorinfo_immune_criticals">Immunise contre les coups critiques</string>
|
||||
<string name="traitsinfo_criticalhit_effectivechance">Taux de coups critiques : </string>
|
||||
|
||||
<!-- =========================================== -->
|
||||
<!-- Added in v0.7.0 -->
|
||||
|
||||
<string name="localize_resources_from_mo_filename">fr.mo</string>
|
||||
</resources>
|
||||
|
||||
@@ -320,4 +320,9 @@
|
||||
<item>2.0f</item>
|
||||
</string-array>
|
||||
|
||||
<!-- =========================================== -->
|
||||
<!-- Added in v0.7.0 -->
|
||||
|
||||
<string name="localize_resources_from_mo_filename">it.mo</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -513,4 +513,10 @@
|
||||
<string name="skill_longdescription_concussion">あなたの命中率より %1$d 以上回避率が低い敵に攻撃するたび、その攻撃は %2$d%% の確率で対象に脳震盪(concussion)を起こします。concussionは攻撃に関する戦闘能力を劇的に下げ、対象は有効な攻撃を当てることが難しくなります。</string>
|
||||
|
||||
<string name="about_button4">About</string>
|
||||
|
||||
<!-- =========================================== -->
|
||||
<!-- Added in v0.7.0 -->
|
||||
|
||||
<string name="localize_resources_from_mo_filename">ja.mo</string>
|
||||
|
||||
</resources>
|
||||
@@ -559,5 +559,10 @@ Translated by toudi5-bełchatów
|
||||
<string name="preferences_dialog_overwrite_savegame_title">Potwierdź nadpisanie gry</string>
|
||||
<string name="preferences_dialog_overwrite_savegame">Zadaje pytanie zawsze, gdy chcesz nadpisać grę na slocie, który jest już zajęty.</string>
|
||||
|
||||
|
||||
<!-- =========================================== -->
|
||||
<!-- Added in v0.7.0 -->
|
||||
|
||||
<string name="localize_resources_from_mo_filename">pl.mo</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -559,4 +559,9 @@
|
||||
<string name="preferences_dialog_overwrite_savegame_title">Confirma re-escrita de salvamento</string>
|
||||
<string name="preferences_dialog_overwrite_savegame">Pergunta o que deve ser feito caso tente-se gravar sobre um salvamento anterior.</string>
|
||||
|
||||
<!-- =========================================== -->
|
||||
<!-- Added in v0.7.0 -->
|
||||
|
||||
<string name="localize_resources_from_mo_filename">pt-rBR.mo</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -475,4 +475,9 @@
|
||||
<string name="preferences_optimized_drawing_title">Optimized drawing</string>
|
||||
<string name="preferences_optimized_drawing">Desactiva esta opção caso apareçam artefactos gráficos. Ao activar esta opção apenas serão redesenhados no écrã os blocos alterados em cada fotograma.</string>
|
||||
|
||||
<!-- =========================================== -->
|
||||
<!-- Added in v0.7.0 -->
|
||||
|
||||
<string name="localize_resources_from_mo_filename">pt.mo</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -558,5 +558,9 @@
|
||||
<string name="preferences_dialog_overwrite_savegame_title">Перезаписать сохранение</string>
|
||||
<string name="preferences_dialog_overwrite_savegame">Настройка диалога подтверждения при попытке перезаписать сохранение</string>
|
||||
|
||||
<!-- =========================================== -->
|
||||
<!-- Added in v0.7.0 -->
|
||||
|
||||
<string name="localize_resources_from_mo_filename">ru.mo</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -564,6 +564,7 @@
|
||||
<string name="heroinfo_useitem_cost">Use item cost (AP):</string>
|
||||
<string name="combat_result_monstermoved">%1$s moves.</string>
|
||||
<string name="combat_log_title">Combat log</string>
|
||||
<string name="localize_resources_from_mo_filename"></string>
|
||||
<string name="conversation_reward_quest_finished">[Quest completed: \"%1$s\"]</string>
|
||||
<string name="conversation_reward_quest_updated">[Quest updated: \"%1$s\"]</string>
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public final class ConversationLoader {
|
||||
return conversationCollection.getPhrase(phraseID);
|
||||
}
|
||||
|
||||
TranslationLoader translationLoader = new TranslationLoader(r.getAssets());
|
||||
TranslationLoader translationLoader = new TranslationLoader(r.getAssets(), r);
|
||||
ConversationListParser conversationListParser = new ConversationListParser(translationLoader);
|
||||
int resourceID = resourceIDsPerPhraseID.get(phraseID);
|
||||
conversationCollection.initialize(conversationListParser, ResourceLoader.readStringFromRaw(r, resourceID));
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class ResourceLoader {
|
||||
|
||||
final int mTileSize = world.tileManager.tileSize;
|
||||
|
||||
TranslationLoader translationLoader = new TranslationLoader(r.getAssets());
|
||||
TranslationLoader translationLoader = new TranslationLoader(r.getAssets(), r);
|
||||
|
||||
DynamicTileLoader loader = new DynamicTileLoader(world.tileManager.tileCache);
|
||||
prepareTilesets(loader, mTileSize);
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.gpl.rpg.AndorsTrail.resource;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Resources;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
@@ -11,21 +14,30 @@ import java.nio.charset.Charset;
|
||||
public final class TranslationLoader {
|
||||
private final BinaryMoFileParser parser;
|
||||
|
||||
public TranslationLoader(AssetManager mgr) {
|
||||
BinaryMoFileParser parser = null;
|
||||
public TranslationLoader(AssetManager mgr, Resources res) {
|
||||
this.parser = createParser(mgr, res);
|
||||
}
|
||||
|
||||
private static final String translationDir = "translation" + File.separator;
|
||||
private static BinaryMoFileParser createParser(AssetManager mgr, Resources res) {
|
||||
String translationFilename = res.getString(R.string.localize_resources_from_mo_filename);
|
||||
if (translationFilename == null || translationFilename.length() <= 0) return null;
|
||||
|
||||
translationFilename = translationDir + translationFilename;
|
||||
|
||||
try {
|
||||
InputStream is = mgr.open("messages.mo");
|
||||
parser = new BinaryMoFileParser(is);
|
||||
InputStream is = mgr.open(translationFilename);
|
||||
return new BinaryMoFileParser(is);
|
||||
} catch (IOException e) {
|
||||
L.log("ERROR: Reading from translation asset failed: " + e.toString());
|
||||
L.log("ERROR: Reading from translation asset \"" + translationFilename + "\" failed: " + e.toString());
|
||||
return null;
|
||||
}
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
private String tr(String s) {
|
||||
if (s == null) return null;
|
||||
if (s.length() <= 1) return s;
|
||||
if (parser == null) return s;
|
||||
if (s.length() <= 1) return s;
|
||||
try {
|
||||
//String t = parser.translate(s);
|
||||
//L.log(translations.size() + " : " + s + " -> " + t);
|
||||
@@ -46,14 +58,13 @@ public final class TranslationLoader {
|
||||
public String translateItemCategoryName(String s) { return tr(s); }
|
||||
public String translateActorConditionName(String s) { return tr(s); }
|
||||
public String translateItemTypeName(String s) { return tr(s); }
|
||||
public String translateItemTypeDescription(String s) {return tr(s); }
|
||||
public String translateMonsterTypeName(String s) { return tr(s); }
|
||||
public String translateQuestName(String s) { return tr(s); }
|
||||
public String translateQuestLogEntry(String s) { return tr(s); }
|
||||
public String translateConversationPhrase(String s) { return tr(s); }
|
||||
public String translateConversationReply(String s) { return tr(s); }
|
||||
|
||||
//public static HashSet<String> translations = new HashSet<String>();
|
||||
|
||||
private static final class BinaryMoFileParser {
|
||||
private final InputStream is;
|
||||
private final BufferedInputStream reader;
|
||||
@@ -86,7 +97,6 @@ public final class TranslationLoader {
|
||||
byte[] bytes = s.getBytes(charset);
|
||||
byte[] translation = find(bytes);
|
||||
if (translation == null || translation.length <= 0) return s;
|
||||
//translations.add(s);
|
||||
return new String(translation, charset);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ public final class ItemTypeParser extends JsonCollectionParserFor<ItemType> {
|
||||
public Pair<String, ItemType> parseObject(JSONObject o) throws JSONException {
|
||||
final String id = o.getString(JsonFieldNames.ItemType.itemTypeID);
|
||||
final String itemTypeName = translationLoader.translateItemTypeName(o.getString(JsonFieldNames.ItemType.name));
|
||||
final String description = translationLoader.translateItemTypeDescription(o.optString(JsonFieldNames.ItemType.description, null));
|
||||
final ItemTraits_OnEquip equipEffect = itemTraitsParser.parseItemTraits_OnEquip(o.optJSONObject(JsonFieldNames.ItemType.equipEffect));
|
||||
final ItemTraits_OnUse useEffect = itemTraitsParser.parseItemTraits_OnUse(o.optJSONObject(JsonFieldNames.ItemType.useEffect));
|
||||
final ItemTraits_OnUse hitEffect = itemTraitsParser.parseItemTraits_OnUse(o.optJSONObject(JsonFieldNames.ItemType.hitEffect));
|
||||
@@ -46,7 +47,7 @@ public final class ItemTypeParser extends JsonCollectionParserFor<ItemType> {
|
||||
id
|
||||
, ResourceParserUtils.parseImageID(tileLoader, o.getString(JsonFieldNames.ItemType.iconID))
|
||||
, itemTypeName
|
||||
, o.optString(JsonFieldNames.ItemType.description, null)
|
||||
, description
|
||||
, itemCategories.getItemCategory(o.getString(JsonFieldNames.ItemType.category))
|
||||
, o.optInt(JsonFieldNames.ItemType.displaytype, ItemType.DISPLAYTYPE_ORDINARY)
|
||||
, hasManualPrice
|
||||
|
||||
Reference in New Issue
Block a user