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>
This commit is contained in:
@@ -62,7 +62,7 @@ class TranslationServer : public Object {
|
||||
String default_country;
|
||||
HashSet<String> supported_countries;
|
||||
};
|
||||
static Vector<LocaleScriptInfo> locale_script_info;
|
||||
static inline Vector<LocaleScriptInfo> locale_script_info;
|
||||
|
||||
struct Locale {
|
||||
String language;
|
||||
@@ -82,12 +82,13 @@ class TranslationServer : public Object {
|
||||
Locale(const TranslationServer &p_server, const String &p_locale, bool p_add_defaults);
|
||||
};
|
||||
|
||||
static HashMap<String, String> language_map;
|
||||
static HashMap<String, String> script_map;
|
||||
static HashMap<String, String> locale_rename_map;
|
||||
static HashMap<String, String> country_name_map;
|
||||
static HashMap<String, String> country_rename_map;
|
||||
static HashMap<String, String> variant_map;
|
||||
static inline HashMap<String, String> language_map;
|
||||
static inline HashMap<String, String> script_map;
|
||||
static inline HashMap<String, String> locale_rename_map;
|
||||
static inline HashMap<String, String> country_name_map;
|
||||
static inline HashMap<String, String> country_rename_map;
|
||||
static inline HashMap<String, String> variant_map;
|
||||
static inline HashMap<String, String> plural_rules_map;
|
||||
|
||||
void init_locale_info();
|
||||
|
||||
@@ -113,6 +114,7 @@ public:
|
||||
String get_country_name(const String &p_country) const;
|
||||
|
||||
String get_locale_name(const String &p_locale) const;
|
||||
String get_plural_rules(const String &p_locale) const;
|
||||
|
||||
PackedStringArray get_loaded_locales() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user