Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language stuff #108

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Language stuff #108

wants to merge 8 commits into from

Conversation

t0stiman
Copy link
Collaborator

@t0stiman t0stiman commented Dec 20, 2024

  • added ability to translate station names
  • fixed "Failed to find locale language" warning (it reported the wrong language)
  • added more languages and credited the translators

Fixes #107

@t0stiman t0stiman requested a review from Insprill December 20, 2024 12:07
Copy link
Owner

@Insprill Insprill left a comment

Choose a reason for hiding this comment

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

How are map-specific locales supposed to be created? I don't see anything changed on the editor side.

@@ -2,7 +2,7 @@
<Import Project="../UserProperties.props" Condition="Exists('../UserProperties.props')" />
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<LangVersion>7.3</LangVersion>
<LangVersion>9</LangVersion>
Copy link
Owner

Choose a reason for hiding this comment

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

What was this bump necessary for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

1>Locale.cs(30,105): Error CS8370 : Feature 'target-typed object creation' is not available in C# 7.3. Please use language version 9.0 or greater.
1>Locale.cs(63,39): Error CS8370 : Feature 'target-typed object creation' is not available in C# 7.3. Please use language version 9.0 or greater.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

private static ReadOnlyDictionary<string, Dictionary<string, string>> mapSpecificTranslations = new (new Dictionary<string, Dictionary<string, string>>());

Copy link
Owner

Choose a reason for hiding this comment

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

In that case, simply don't use the new style of constructor. We should take a C# version bump more seriously and do a proper upgrade that takes advantage of it, but not now.

@t0stiman
Copy link
Collaborator Author

t0stiman commented Feb 2, 2025

How are map-specific locales supposed to be created? I don't see anything changed on the editor side.

Create locale.csv in the same folder as info,json of the map. For example:

locale.csv

@Insprill
Copy link
Owner

Insprill commented Feb 2, 2025

You aren't supposed to ever create the zip manually though, when you build the map from the editor that should be the zip you distribute. There needs to be good editor tooling for creating localizations.

How much work would be involved with switching to the localization library most other mods now use? I think that would be a better route than continuing to reinvent the wheel, assuming it covers all our needs.

@WhistleWiz
Copy link
Collaborator

To read the localised strings added with Language Helper, it's the same method as reading vanilla keys (Localisation.L(key)).

Wherever you need it, add a TranslationData field, which will handle the language -> string values. Key is defined separately, which can keep the current key generation method. Be aware that unity cannot serialise that custom class in an asset bundle so you should convert it to an xml or json and then reassign later.

As for adding the strings to the game, you create a new TranslationInjector(sourceId), then call AddTranslations(key, data) on that instance. It also includes ways to load a .csv directly.

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.

Option to translate station names
3 participants