Localization problem

Place to get help with not working mods / modding interface.
Post Reply
Pi-C
Smart Inserter
Smart Inserter
Posts: 1648
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Localization problem

Post by Pi-C »

I'm currently working on the localizations of Bio Industries.

Code: Select all

[fluid-name]
bi-biomass=Algen-Biomasse

[item-name]
fertiliser=Düngemittel

[recipe-name]
bi-biomass-1=Produktion von Algen-Biomasse mit __ITEM__fertiliser__
bi-biomass-2=Produktion von __FLUID__bi-biomass__  mit __ITEM__fertiliser__
The string for recipe-name.bi-biomass-1" will be displayed correctly, with __ITEM__fertiliser__ being replaced by the string set in item-name.fertiliser. The same thing doesn't work with fluids, though. The string for recipe-name.bi-biomass-2 will be just the placeholder __FLUID__bi-biomass__ i.e., __FLUID__bi-biomass__ wont be replaced with fluid-name.bi-biomass. I guess it should be possible somehow to reference the names of different fluids -- but how is it done? :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Pi-C
Smart Inserter
Smart Inserter
Posts: 1648
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Localization problem

Post by Pi-C »

OK, I can change the string in recipes by using

Code: Select all

[fluid-name]
bi-biomass=Algen-Biomasse

[item-name]
fertiliser=Düngemittel

[recipe-name]
bi-biomass-2=Produktion von __1__  mit __ITEM__fertiliser__
in the locale file and

Code: Select all

recipe.localised_name = {"recipe-name.bi-biomass-2", {"fluid-name.bi-biomass"}}
in the recipe definition. But how about mod-settings? There's no other place where I could pass on the fluid name as an argument. Do I really have to jump through hoops, e.g. declaring a dummy item and use

Code: Select all

data.raw.item[fluid_name].localised_name = {"fluid-name.X"}
and then use

Code: Select all

bi-biomass-2=Produktion von __ITEM__X__  mit __ITEM__fertiliser__
in the locale?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Bilka
Factorio Staff
Factorio Staff
Posts: 3129
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Localization problem

Post by Bilka »

Pi-C wrote:
Thu Mar 25, 2021 4:56 pm
But how about mod-settings?
localised name like recipe? Your post doesn't really give context as to why that wouldnt work.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1648
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Localization problem

Post by Pi-C »

Bilka wrote:
Thu Mar 25, 2021 5:16 pm
Pi-C wrote:
Thu Mar 25, 2021 4:56 pm
But how about mod-settings?
localised name like recipe? Your post doesn't really give context as to why that wouldnt work.
In the locale file, it's only possible to use __ENTITY__entity-name__ and __ITEM__item-name__, but not __FLUID__fluid-name__:

Code: Select all

[fluid-name]
bi-biomass=Biomasse

[item-name]
fertilizer=Düngemittel 08/15

[recipe-name]
bi-biomass-2=Produktion von __FLUID__bi-biomass__  mit __ITEM__fertilizer__
will give you this:
fluid-name.png
fluid-name.png (23.14 KiB) Viewed 1497 times
Work-around for recipes:

Code: Select all

[fluid-name]
bi-biomass=Biomasse

[item-name]
fertilizer=Düngemittel 08/15

[recipe-name]
bi-biomass-2=Produktion von __1__  mit __ITEM__fertilizer__

data:extend({
    {
      type = "recipe",
      name = "bi-biomass-2",
      localised_name = {"recipe-name.bi-biomass-2", {"fluid-name.bi-biomass"}},
      …
     }
})
This will work as expected because {"fluid-name.bi-biomass"} is passed on as an argument directly in the recipe's localized name:
fluid-name-2.png
fluid-name-2.png (22.2 KiB) Viewed 1497 times
But it wouldn't work for mod settings:

Code: Select all

[mod-setting-name]
BI_Bio_Fuel=Aktivieren: __FLUID__bi-biomass__
settings.png
settings.png (41.68 KiB) Viewed 1497 times
Using "__1__" instead of "__FLUID_bi-bio-mass__" is no option here because there's no way to pass on an argument externally. However, it does work with item names:

Code: Select all

[mod-setting-name]
BI_Bio_Fuel=Aktivieren: __ITEM__fertilizer__
settings-2.png
settings-2.png (43.02 KiB) Viewed 1497 times
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
ickputzdirwech
Filter Inserter
Filter Inserter
Posts: 768
Joined: Sun May 07, 2017 10:16 am
Contact:

Re: Localization problem

Post by ickputzdirwech »

EDIT: looks like I was a bit slow :)

I would guess he means string settings with allowed values like {"fluid-1", "fluid-2}. Since you can't define a localised name for the allowed values in the prototype you couldn't use

[string-mod-setting]
setting-name-fluid-1=__1__
setting-name-fluid-2=__1__

As a workaround (since __FLUID__fluid-name__ unfortunately doesn't exist) you could try something like

[item-name]
dummy-fluid-1=Fluid 1
dummy-fluid-2=Fluid 2

[string-mod-setting]
setting-name-fluid-1=__ITEM__dummy-fluid-1__
setting-name-fluid-2=__ITEM__dummy-fluid-2__

May I also point to this question around the same issue: 90493. I wish there were some more built in parameters like __TECHNOLOGY__ and __RECIPE__.
Last edited by ickputzdirwech on Sat Mar 27, 2021 8:36 am, edited 1 time in total.
Mods: Shortcuts for 1.1, ick's Sea Block, ick's vanilla tweaks
Tools: Atom language pack
Text quickly seems cold and unfriendly. Be careful how you write and interpret what others have written.
- A reminder for me and all who read what I write

Bilka
Factorio Staff
Factorio Staff
Posts: 3129
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Localization problem

Post by Bilka »

Pi-C wrote:
Thu Mar 25, 2021 6:38 pm
But it wouldn't work for mod settings: Using "__1__" instead of "__FLUID_bi-bio-mass__" is no option here because there's no way to pass on an argument externally.
Yes, there is, as I said. localised_name on the prototype, just how you did it with the recipe.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1648
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Localization problem

Post by Pi-C »

Bilka wrote:
Thu Mar 25, 2021 7:10 pm
Pi-C wrote:
Thu Mar 25, 2021 6:38 pm
But it wouldn't work for mod settings: Using "__1__" instead of "__FLUID_bi-bio-mass__" is no option here because there's no way to pass on an argument externally.
Yes, there is, as I said. localised_name on the prototype, just how you did it with the recipe.
Oh, my… That was so obvious, wasn't it? Thanks for the reminder!
ickputzdirwech wrote:
Thu Mar 25, 2021 6:44 pm
May I also point to this question around the same issue: 90493. I wish there were some more built in parameters like __TECHNOLOGY__ and __RECIPE__.
I still agree with this, however. Couldn't it be made that we could use parameter __X__for every pair of vanilla categories "[X-name] and [X-description]"? It would be so much easier as one would not see anonymous parameters (__1__ etc.) in the strings, but could get the context immediately, without having to switch to another file.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
ickputzdirwech
Filter Inserter
Filter Inserter
Posts: 768
Joined: Sun May 07, 2017 10:16 am
Contact:

Re: Localization problem

Post by ickputzdirwech »

And even though it isn’t the issue Pi-C is having: It doesn’t work for the options of string mod settings. You can’t define a localised name for them in the prototype.

(I did a mistake in my post above. I edited and it should be correct now.)
Mods: Shortcuts for 1.1, ick's Sea Block, ick's vanilla tweaks
Tools: Atom language pack
Text quickly seems cold and unfriendly. Be careful how you write and interpret what others have written.
- A reminder for me and all who read what I write

Post Reply

Return to “Modding help”