How do I overwrite a string from locales/en.json?

This is what I tried, but didn’t worked.

{
   "ui": {
      "shell": {
         "select_settlement": {
            "terrain_codes": {
               "water": "replace text",
               "plains_1": "replace text",
               "foothills_4": "new string",
               "foothills_5": "new string"
            }
         }
      }
   },
   "data": {
      "biome": {
         "new_biome": {
            --here goes biome name and description, this is working
         }
      }
   }
}

The lines with “replace text” already exist at default stonehearth en.json as “Water” and “Plains” and are the ones I want to change for my biome. The game is ignoring my changes.

The lines with “new string” are new. The game only have up to foothills_3 and I’m going to use 5. These also didn’t work.

These texts controls what you see when you hover your mouse at a tile in your map selection screen, and at the right it displays info like name of the tile (what I’m trying to change), vegetation, minerals, etc…

Did you try with a mixinto or with an override? :sweat:

My manifest is like this:

{
	"info" : {
		"name" : "new_biome",
		"version" : 2
	},
	"default_locale": "en",
	"mixintos" :  {
		"stonehearth:biome:index": "file(data/biome/index.json)"
	}
}

It is the only way I know to add text. I have the “en.json” in a “locales” folder at the root of my mod, sibling level with the “manifest.json” file

Yeah but I think the “replace text” won’t be used. The original files must be pointing to the stonehearth en.json file.
You should try to force the game to pick your file, or part of your file for those. Not sure how it would work…

There might be something hardcoded somewhere that is preventing your options from working =(

Oh no, more work for small results… :frowning:
I just get out of a lot of lua files…

Hmm… But your foothills_4 and 5 should work correctly without fiddling with the translation, right?

I guess, I thought it would just do something similar to what the code does with mountains, where it checks for the string “mountain_” + the layer number. Maybe for foothills it is checking just up to layer 3, not as dynamic as mountains. I will dig into it later.

2 Likes

I got it working, here is how:
(manifest.json)

{
	"info" : {
		"name" : "new_biome",
		"version" : 2
	},
	"default_locale": "en",
	"mixintos" :  {
		"stonehearth:biome:index": "file(data/biome/index.json)",
		"/stonehearth/locales/en.json": "file(locales/en.json)"
	}
}

I mixinto en.json into stonehearth default en.json. Both the new lines and the overwrite lines worked.

But now I doubt this is the right way to do it. For example, it kind of defeats the purpose of a language file and I think it even blocks the ability to translate it. I’m not sure, but if someone were to translate it he wouldn’t be able as the mod is only "mixinto"ing the en.json. Is it right?

I think I’m going to tag @Wiese2007 cause he is always doing translation works. Wiese, how bad is this mess?

2 Likes

That was my first guess, hence my first question.
But it generates that problem…

Could you have your “overriding” keys on the mixinto, and your own, new / added keys on your en.json ?
Would that work?

No, I tried a language file with only the new keys (without the water and plains overwrites) and it didn’t read those… :frowning:

Yeah, so probably something hardcoded somewhere -.-

It’s like the water color, or the path for the building icons in javascript…

at first dont hear at relyss ^^ you dont need the locales string in the manifest ^^ because stonehearth takes automatically the en.json from your mod - only if someone like me wants to add his language to your mod i must add my translation to your mod :wink:

for the en.json it looks good but now you must add this strings also in the biome - so that when the game reads your biome it see ahhh here i can add a name like “replace text”.

for example: l18n(new_biome:ui.shell.select_settlement.terrain_codes.water)

for this like i know and searched the existing terrainnames are linked to the select_settlement.js

terrainType = i18n.t(‘stonehearth:ui.shell.select_settlement.terrain_codes.’ + cell.terrain_code);

3 Likes

I don’t understand. Removing the “default_locale”: “en”, made it not recognize my strings anymore.

So I will need to also have the .js file and on that file I would add the new “lookup” l18n(new_biome:ui… instead of the i18n.t('stonehearth:ui

So I downloaded you mod to get a better understand of how the translation works.
First, congrats on doing it, it is an impressive and huge work.
But some things got me confused, like, I checked how you translated my archipelago biome, and you are overwriting a de.json file, but I have no such file in my mod… So, the game actually creates such a file if you select german as language and then your mod overwrites it?

ok the default_locale must be in it - but you doesnt need this “/stonehearth/locales/en.json”: “file(locales/en.json)” because the default_locale says your mod is in english and it will automatically use the en.json of your mod.

for my mod - yes it adds then the file de.json to your mod - so that when i say ingame i want german he checks the mods for the german file de.json ^^

for the l18n … its very difficult in this case ^^ i think you will need for this to make an mixinfile that add this strings to the en.json of the stonehearth.smod … normally thats not neccessary but is hardcoded - so it will not look for strings from other mods for this.

so just copy your en.json to an folder like mixin - add only the string for the terrain_codes there and mixit in the en.json from stonehearth like you have done in your maninfest

here the string ^^

“stonehearth/locales/de.json” : “file(mixins/terrain_codes.json)”,

2 Likes

Hi I had some throubles with the localisation as wel, i don’t know if this fixes your problem, but it did mine so here we go:

I added and a dutch translation and extra own en language file to reference to without overriding the default stonehearth one.

#Manifest code

 "overrides": {
      "stonehearth/locales/nl.json": "file(locales/stonehearth/nl.json)",
      "agora/locales/nl.json": "file(locales/agora/nl.json)",
      "agora/locales/en.json": "file(locales/agora/en.json)",
...
}

the stonehearth locales nl is to add translations for things in stonhearth “en” same as wiese does with ge files. The two files beneed our the i18n files of my own project. 1 for “en” and 1 for “nl”

#Partial mage job description (use of my own en file for the i18n)

   "type": "job",
   "job_id": "mage",
   "alias": "agora:jobs:mage",
   "controller": "agora:class:mage",
   "display_name": "i18n(agora:jobs.mage.mage_description.display_name)",
   "description": "i18n(agora:jobs.mage.mage_description.description)",
   "requirements": "i18n(agora:jobs.mage.mage_description.requirements)",
   "talisman_uri": "agora:mage:talisman",
   "default_stance": "passive",
   "promotion_activity_name": "promote_mage",
   "abilities": "file(mage_abilities)",
   "is_mage" : true,
...
}

So no need to change any js file when done like this.

That is the right way of doing it, and is what I normally do.

But my case now is that I’m not doing translations (or preparing it for translations), just changing a word. For example, in my archipelago biome I needed to change the word “Water” at the map screen to Sea/Ocean.

Just adding a en.json doesn’t work, cause the code where this will be read is at a .js file
mods\stonehearth\ui\shell\select_settlement\select_settlement.js:
The code in it:
terrainType = i18n.t(‘stonehearth:ui.shell.select_settlement.terrain_codes.’ + cell.terrain_code);
instead of this
terrainType = i18n.t(‘archipelago:ui.shell.select_settlement.terrain_codes.’ + cell.terrain_code);

So I mixinto. That way, my changed strings are added into the stonehearth and read from the .js. Or instead, I could overwrite the .js to change that line to read from my en.json, not stonehearth en.

the problem with this way is that the mod never will be localisable ^^ only when i override your en.json that he can mixin this to the stonehearth en.json ^^ thats not the best way ^^

so the easiest part would be to ask for help @yshan or @sdee

So it is better to overwrite the .js, right? Because then I can call the en.json from archipelago, and translator could overwrite my en.json. If they would translate the stonehearth en.json, that translation would leak even to other biomes.

that would be also an option but then you need to check every update if there are a change in the original.js file ^^

Yeah… :frowning:
Cause there is no way to mixinto or replace just that fraction of the code, right?