X Tutup
Skip to content

Make ships translatable#6103

Merged
zonkmachine merged 1 commit intopioneerspacesim:masterfrom
zonkmachine:assassino
Nov 25, 2025
Merged

Make ships translatable#6103
zonkmachine merged 1 commit intopioneerspacesim:masterfrom
zonkmachine:assassino

Conversation

@zonkmachine
Copy link
Member

@zonkmachine zonkmachine commented Mar 30, 2025

Improve text by making the ship names translatable.
Example of use: In the Assassination module the answer to chat question "Where do I find {target}" is always the same and the ending looks a bit off as the string doesn't cater for the ship model, a/an.

The ship is Wave and has registration ID QA-7856.

The example above has been temporarily improved by adding article 'a' as by chance it fits in with all ship models except AC-33, which by chance isn't used in the Assassination module.

The ship is a Wave and has registration ID QA-7856.

But this is now permanently solved by adding translations of the ship names into a separate 'data/lang/ships' directory which allows a limited grammatical subset of ship names.

  "CORONATRIX_BASE": {
    "description": "ship name - base form",
    "message": "Koronatrix"
  },
  "CORONATRIX_INDEF": {
    "description": "ship name - indefinite form",
    "message": "a Coronatrix"
  },
  "CORONATRIX_DEF": {
    "description": "ship - definite form",
    "message": "the Coronatrix"
  },

A key in the ship models, i18n_key is added, which contains the upper case ship identifier that pairs with the form suffix needed. CORONATRIX .. "_INDEF" = 'a Coronatrix'

The forms available are:
The base form with no article (_BASE): "Model: Natrix"
The indefinite form, a/an (_INDEF): "an AC-33"/"a Dropstar"
The definite form, the (_DEF):"The Bluenose is severely damaged and currently in orbit around Titan.".

Please note that this is intended to be a small language tool and not a complete translation tool.

Code example:

local ship = ShipDef[ad.shipid].i18n_key            -- 'NATRIX'

local ship_def = ls[ship .. "_DEF"],                -- 'NATRIX_DEF' - 'the Natrix'
print("We're counting on " .. ship_def .. " to give us some resistance!)

TODO:

  • ship names in System Map/Object info
  • New Game Window

Related. Ship descriptions, translatable: #1693

@impaktor
Copy link
Member

Would "of model" fix it?

"of model AC..."
"of model Wave"

or "of make/", "type"?

@bszlrd
Copy link
Contributor

bszlrd commented Mar 31, 2025

Out of scope, but how about having a "a" or "an" defined in the ship.jsons, so missions could see which to use? Or I'm overthinking again?

@zonkmachine
Copy link
Member Author

Would "of model" fix it?

"of model AC..." "of model Wave"

or "of make/", "type"?

You would make it grammatically correct but it's not how people speak. It would still be annoying.

Out of scope, but how about having a "a" or "an" defined in the ship.jsons, so missions could see which to use? Or I'm overthinking again?

I think you would need to make the ships translatable somehow but I don't know if that would work in a json file. Maybe have ship terms defined in a lua file, make, synonyms, etc. and that could be easily translatable.

@zonkmachine
Copy link
Member Author

OK, I'll try a simple "ships" json file.

@zonkmachine
Copy link
Member Author

As it turns out the AC33 doesn't seem to show up as a target vehicle. The model seem to be guided by MissionUtils.ShipTemplates.GenericMercenary . I fail to grasp the selection process.

I have made a simple /data/lang/ships/en.json file with modelName as key and it seem to work just fine.

    "ac33": {
        "description": "",
        "message": "an AC-33 Dropstar"
    },
    "bluenose": {
        "description": "",
        "message": "a Bluenose"
    },

@zonkmachine
Copy link
Member Author

This now works but only with new games so it wouldn't be for the next release. I think maybe, especially if the AC-33 isn't even ever selected for assassination targets, that the first one-liner still has the merits of just bringing good and you can add it to the next release. The new fuller version is better in the long run and can be applied to other modules as well.

@zonkmachine
Copy link
Member Author

"a Pumpkinseed Police"

I guess this wouldn't look good in the game.

The ship is a Pumpkinseed Police and has registration id {shipregid}.

Maybe

"a Pumpkinseed police ship" ?
The ship is a Pumpkinseed police ship and has registration id {shipregid}.

@zonkmachine
Copy link
Member Author

assassino

@impaktor
Copy link
Member

impaktor commented Apr 2, 2025

Out of scope, but how about having a "a" or "an" defined in the ship.jsons, so missions could see which to use?

Sounds like an ugly hack that would also only be specific to English.

I'm not convinced the best and simplest work-around is to re-word the context in which it is used, something along the lines of my initial suggestion, but that's just, like, my opinion.

@zonkmachine
Copy link
Member Author

I'm not convinced the best and simplest work-around is to re-word the context in which it is used, something along the lines of my initial suggestion

Unfortunately that creates a language that isn't flowing very well and that's how it's done all over the code. I've tried rephrasing stuff like that and it doesn't work as well as the real deal. On the other hand, I've poked around ways to address it and in precisely every case it runs away in complexity super fast. My wet dream right now is to just pipe the strings, at least some of them, to an external app that can fix them up on the fly with at least the most basic stuff, like a/an or genitive s or whatever is most worth it in other languages.

I think this way of doing it here, by making the ships translatable, is a reasonable way of doing it. Lot's of strings but a simple to understand idea so it should be easy on the translators. It will take some consideration though. You could add more fields for the ships so some of them could have alternative names or nicknames. The AC-33 could be either AC-33 or Dropstar or both.

I think it is also reasonable to merge the original one-line fix for the up coming stable bug fix. It's a small change but that string is on ever single assassination mission and it looks bad.

I approve of this message.

@zonkmachine
Copy link
Member Author

    "ac33": {
        "description": "",
        "message": "an AC-33 Dropstar"
    },

As I understand it, as these are new translations, the strings here would be pushed to all other languages and come out with English articles. That wouldn't be good. Is there a way to do a first push to Transifex with ships.json without articles so the translations will look the same as today and then change the strings in a later commit?

@zonkmachine
Copy link
Member Author

push to Transifex with ships.json without articles

Do all languages at the same time and with the same English translation without article or with a rough automatic translation? This is where we could use Grok right?

@impaktor
Copy link
Member

impaktor commented Apr 3, 2025

Is there a way to do a first push to Transifex with ships.json without articles so the translations will look the same as today and then change the strings in a later commit?

No, not that I know of.

Do all languages at the same time and with the same English translation without article or with a rough automatic translation? This is where we could use Grok right?

Hm? When you push they get the default English until translated. However, the cron-job that pulls the strings back to master doesn't like to run, so at the moment nothing gets back to master until I kick the machine (which we also do when releasing new version)

@zonkmachine
Copy link
Member Author

When you push they get the default English until translated.

Yes, but the strings are still in the English original. If we merge this, all languages will show ups with the English article. I looked at some language files and it looks like Swedish, Danish, Italian, and French, all could use their ship file with just the current name added. You don't need to be a translator to manage that. If we pushed these file pretranslated, would Transifex accept that?

@zonkmachine
Copy link
Member Author

zonkmachine commented Apr 3, 2025

If we pushed these file pretranslated, would Transifex accept that?

This is what I mean. Last commit sees an example of sv.json but with just the same ship names that the string sees today.


    "ac33": {
        "description": "",
        "message": "AC-33 Dropstar"
    },

@zonkmachine
Copy link
Member Author

OK. Definitely not a quick fix no longer.

Added strings for Search and Rescue too. The variable names are not unison for the modules. Will fix.

@zonkmachine zonkmachine changed the title Assassination - article quick fix Make ships translatable Apr 3, 2025
@impaktor
Copy link
Member

impaktor commented Apr 5, 2025

Would like thoughts from @sturnclaw here, on if adding a translation module ship is the best solution (and if it is to be added, would the name be "ships-core" or "ships"?)

(Besides, this will need further hooking up into transifex upon merge, by me)

@zonkmachine zonkmachine marked this pull request as draft April 5, 2025 09:41
@zonkmachine
Copy link
Member Author

zonkmachine commented Apr 5, 2025

(Besides, this will need further hooking up into transifex upon merge, by me)

It's a bit like #5852. Did you have to do anything special on merge?
Edit: Got it. You temporarily added a script to parse all translation files in that PR.

@impaktor
Copy link
Member

impaktor commented Apr 5, 2025

@zonkmachine no, difference is this adds a new module, that needs some configuring on transifex side.

@Mc-Pain
Copy link
Contributor

Mc-Pain commented Apr 14, 2025

Where do I find {target}
< [...] The target is using Wave with registration ID QA-7856.

@zonkmachine
Copy link
Member Author

Where do I find {target}
< [...] The target is using Wave with registration ID QA-7856.

Please be more verbose. What am I looking at here?

@Mc-Pain
Copy link
Contributor

Mc-Pain commented Apr 14, 2025

Where do I find {target}
< [...] The target is using Wave with registration ID QA-7856.

Please be more verbose. What am I looking at here?

Oops. It was not supposed to be a quote.
It was a suggestion to change answer in order to resolve the issue.

@zonkmachine
Copy link
Member Author

Oops. It was not supposed to be a quote.
It was a suggestion to change answer in order to resolve the issue.

Sorry, English is not my first language. ; )
A - What is that issue?
B - What is the solution?

@zonkmachine
Copy link
Member Author

< [...] The target is using Wave with registration ID QA-7856.

I think you still need an article in there for this sentence to be complete.
The target is using a Wave with registration ID QA-7856.

@zonkmachine
Copy link
Member Author

Rebased on master and squashed. I don't know how to deal with other languages. I can add in all of them with just the base name like in the Swedish ship name file or just leave it to the translators to solve. It may be easier to add in the files via this PR or the untranslated ship names will pop up with English articles where they should not.

@zonkmachine zonkmachine marked this pull request as ready for review October 4, 2025 22:15
Copy link
Contributor

@mwerle mwerle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work, but after looking at this PR I think it is only the start of translating ship names.

Firstly, it only adds translations for "singular" ship names.

Secondly it only updates the Assassination and SearchRescue missions. There are many other areas in the game which display the ship name to the user. While most of the ship names are literally just names, a few contain a descriptor as well, which needs translating.

Furthermore some of the ship names are real nouns/descriptors so it might actually make sense for different languages to provide a different name. For example "Wave"(en) -> "Welle"(de).

---@field id string
---@field path string
---@field name string
---@field i18n_key string
Copy link
Member Author

@zonkmachine zonkmachine Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this belong to notion too?
Edit: it doesn't look like it...

@zonkmachine zonkmachine force-pushed the assassino branch 4 times, most recently from 4a06eb7 to c894d31 Compare November 5, 2025 13:52
@zonkmachine
Copy link
Member Author

Added translatable ship names in the Views.

  • Person Info - Ship Information (model spinner)
  • Ship Market - Ship list and model spinner
  • Equipment Market (model spinner)

@zonkmachine zonkmachine force-pushed the assassino branch 2 times, most recently from 82d6326 to fee221a Compare November 5, 2025 22:42
@zonkmachine

This comment was marked as outdated.

@zonkmachine
Copy link
Member Author

zonkmachine commented Nov 6, 2025

Secondly it only updates the Assassination and SearchRescue missions. There are many other areas in the game which display the ship name to the user. While most of the ship names are literally just names, a few contain a descriptor as well, which needs translating.

I've added translated ship names to the comms/info views now. What other places needs fixing?

Firstly, it only adds translations for "singular" ship names.

I think I will only do 'singular' in this round. If it's needed we can add this later. Are ship models used in plural anywhere in the game apart from maybe the lore?

@sturnclaw I kept the esoteric stuff separate (77bf4de). Esoteric meaning C++. The meaty stuff, (lua) I think I have some kind of grasp on but src/lua/stuff, not so much. I'll let this one rest now, no more force pushes.

@zonkmachine zonkmachine requested a review from mwerle November 6, 2025 15:05
@zonkmachine
Copy link
Member Author

Original post updated and now contains a todo list.

@zonkmachine zonkmachine force-pushed the assassino branch 2 times, most recently from 2b731d4 to e27f70f Compare November 14, 2025 17:46
@zonkmachine
Copy link
Member Author

Squashed to 1 commit. There are still two todo's that I don't think I can fix. It may not be necessary for a merge however. If you change the name of a ship in translation and not just adjust it grammatically, then the ship name will show the original name in the New Game Window and in game when you select a ship and look at it's name under 'info' in the System Map. It could be two easy fixes but I didn't manage to wrap my mind around it. Other than those two fixes this is ready for a review/play test.

@zonkmachine
Copy link
Member Author

Rebased on master and commit message improved

@zonkmachine
Copy link
Member Author

Fixed ship translations in New Game window.

@zonkmachine
Copy link
Member Author

The last instances I can find that needs ship names translated are these:

table.insert(data, { name = luc.SHIP_TYPE, value = body:GetShipType() })

table.insert(data, { name = luc.SHIP_TYPE, value = ship:GetShipType() })

They use GetShipType() which handles back the 'name' and not the modelName. I'm not sure what's the best way to approach this.

@zonkmachine
Copy link
Member Author

zonkmachine commented Nov 24, 2025

They use GetShipType() which handles back the 'name' and not the modelName. I'm not sure what's the best way to approach this.

Poked it a bit on the C++ side. Now ready for review/test. found a better way

Copy link
Member

@sturnclaw sturnclaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sturnclaw I kept the esoteric stuff separate (77bf4de). Esoteric meaning C++. The meaty stuff, (lua) I think I have some kind of grasp on but src/lua/stuff, not so much. I'll let this one rest now, no more force pushes.

Looks good to me, adding a single field to LuaShipDef is very straightforward and doesn't need much rocket surgery.

I like what I'm seeing here, though I don't see any (current) consumers of the SHIP_DEF form? On the whole, this PR rectifies a long-running deficiency in the localization capability of the game, and you get two big thumbs up for improving that!

* Extend ship with i18n token 'SHIP'
* Add ships for translation in separate file '/data/lang/ships'
* Add support for simplified grammar through tokens
    SHIP - Base form, same as ship translation token
    SHIP_DEF - Deninitive form 'the ship'
    SHIP_INDEF - Indefinite form 'a ship'
@zonkmachine
Copy link
Member Author

zonkmachine commented Nov 25, 2025

I like what I'm seeing here, though I don't see any (current) consumers of the SHIP_DEF form?

I thought it was in use actually. I do remember having a case of 'the kanara' in there but it must have been dropped along the way. Yes. I think I had a problem with it because I wanted it in the beginning of a sentence but ended rewriting it because of the problem with changing case, which now also is fixed.

@zonkmachine
Copy link
Member Author

I like what I'm seeing here, though I don't see any (current) consumers of the SHIP_DEF form?

It's not as easy to work into a text as the indefinite form. The usual use case would be more easily solved by using the more general 'the ship'. It doesn't hurt to keep and maybe it would make more sense in some other language. I almost expect there to be a ship name in there like in: "{SHIP_DEF} the Black Pearl ... " or "{SHIP_DEF} Boaty McBoatface MCXXIV".

@zonkmachine zonkmachine merged commit 029b87b into pioneerspacesim:master Nov 25, 2025
4 checks passed
@zonkmachine zonkmachine deleted the assassino branch November 25, 2025 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

X Tutup