1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

19 Commits

Author SHA1 Message Date
Thaddeus Crews
20430236e7 Merge pull request #107999 from timothyqiu/translation-cleanup
Clean up editor translation related methods
2025-10-15 16:31:09 -05:00
Haoyu Qiu
e882e42e1b Add default plural rules
This makes the PO loader correctly handle the situation where the optional
`Plural-Forms` header field does not exist.

The `Translation` class and its subclasses always have access to valid plural
rules via `_get_plural_rules()`. Plural rules are prioritized:

1. `Translation.plural_rules_override`
2. `TranslationServer.get_plural_rules(locale)`
3. The English plural rules: `nplurals=2; plurals=(n != 1)`

Co-Authored-By: Pāvels Nadtočajevs <7645683+bruvzg@users.noreply.github.com>
2025-09-26 10:51:57 +08:00
Haoyu Qiu
3f03260a21 Cleanup editor translation related methods
- Unify logic for loading editor/property/doc/extractable translations.
- Replace legacy `TranslationServer` methods with translation domains for internal translations.
- Only pre-create editor/property/doc translation domains in editor builds.
- Prevent adding `null` translation.
- Fixes potential loading of duplicated editor translations.
- Add internal `has_translation_for_locale()` instead of calling `get_loaded_translations().has()`.
2025-09-18 20:27:09 +08:00
Thaddeus Crews
e748514112 Merge pull request #105835 from bruvzg/edited_scene_direction
Improve edited scene layout direction detection.
2025-07-09 11:33:11 -05:00
Lukas Tenbrink
d2f9d31270 Make more types (Callable, Signal) conversion to String explicit. 2025-06-10 23:55:35 +02:00
Haoyu Qiu
8d93b6a54c Add translation preview in editor 2025-05-27 07:59:28 +08:00
Haoyu Qiu
bbc6643e4c Remove translation loading logic that was never used 2025-05-12 19:05:20 +08:00
Pāvels Nadtočajevs
03048aa94a Improve edited scene layout direction detection. 2025-04-28 07:57:26 +03:00
Thaddeus Crews
324512e11c Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
Dan Nicholson
6f4fadf65d Expose standardize_locale add_default param publicly
Comparing locales can have surprising outcomes since it standardizes
locales with defaults. For example, zh and zh_CN result in an exact
match since the defaults change them both to zh_Hans_CN. Expose the
add_default parameter publicly with a default of false so the fully
standardized locale can be inspected.
2024-11-21 16:50:31 -07:00
Thaddeus Crews
ebf49317a2 Merge pull request #97923 from kisg/translation_server_siof_fix
Make TranslationServer singleton variable inline.
2024-11-12 12:13:01 -06:00
Dan Nicholson
2dd409fd70 Improve locale comparison
Since 9456454109, country specific locales are always preferred over
country-less locales even when the OS locale country doesn't match. For
example, running the Godot editor with locale es_ES will result in the
es_AR locale being chosen even though the es locale would be better.

The change happened because the score of the es_AR locale and the es
locale are the same when comparing to es_ES. Change this by parsing
locale strings into a Locale structure and decreasing the score when
script, country or variant are set in both but not matched. For the
es_ES case, this causes the es_AR score to be decreased since the
countries don't match. On the other hand, the es locale is not decreased
since it doesn't specify a country.
2024-11-12 06:06:50 -07:00
Haoyu Qiu
acab2d6c1c Cache results for TranslationServer.compare_locales() 2024-10-16 20:54:56 +08:00
Gergely Kis
257633c354 Make TranslationServer singleton variable inline.
This change avoids the problem known as 'Static Initialization Order Fiasco' (SIOF).

See the following PR for more explanation: https://github.com/godotengine/godot/pull/94683

Co-authored-by: Gabor Koncz <gabor.koncz@migeran.com>
2024-10-07 13:47:42 +02:00
Haoyu Qiu
cca54ba4db Move pseudolocalization into TranslationDomain
Also adds command-line option `--editor-pseudolocalization`
2024-09-21 18:28:12 +08:00
Haoyu Qiu
818acb4290 Make editor use translation domains
How editor plugins use this feature:
1. Pick a unique translation domain name.
2. `_enter_tree()`: load translations into that translation domain.
3. Call `set_translation_domain()` for its root UI node.
4. `_exit_tree()`: remove that translation domain.

Plugins can also set the translation domain to `godot.editor` for
nested nodes that should use editor translations. `EditorFileDialog`
automatically does this.
2024-09-17 13:09:44 +08:00
Haoyu Qiu
68d494e24e Add translation domain 2024-09-17 13:09:44 +08:00
rune-scape
0dde931bc9 StringName: Fix empty hash
+Fixed compat hashes
2024-09-09 13:30:02 -07:00
Haoyu Qiu
7343dc3a5d Split TranslationServer into its own file 2024-08-15 15:00:47 +08:00