TranslationServer
The server responsible for language translations.
TranslationServer.swift:17class TranslationServer
The server that manages all language translations. Translations can be added to or removed from it.
Superclasses
class Object
Base class for all other classes in the engine.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
static var pseudolocalizationEnabled: Bool
If
true
, enables the use of pseudolocalization. SeeProjectSettings/internationalization/pseudolocalization/usePseudolocalization
for details.static func addTranslation(Translation?
) Adds a
Translation
resource.static func clear(
) Clears the server from all translations.
static func compareLocales(localeA: String, localeB: String
) -> Int32 Compares two locales and returns a similarity score between
0
(no match) and10
(full match).static func getAllCountries(
) -> PackedStringArray Returns an array of known country codes.
static func getAllLanguages(
) -> PackedStringArray Returns array of known language codes.
static func getAllScripts(
) -> PackedStringArray Returns an array of known script codes.
static func getCountryName(country: String
) -> String Returns a readable country name for the
country
code.static func getLanguageName(language: String
) -> String Returns a readable language name for the
language
code.static func getLoadedLocales(
) -> PackedStringArray Returns an array of all loaded locales of the project.
static func getLocale(
) -> String Returns the current locale of the project.
static func getLocaleName(locale: String
) -> String Returns a locale’s language and its variant (e.g.
"en_US"
would return"English (United States)"
).static func getScriptName(script: String
) -> String Returns a readable script name for the
script
code.static func getToolLocale(
) -> String Returns the current locale of the editor.
static func getTranslationObject(locale: String
) -> Translation? Returns the
Translation
instance based on thelocale
passed in.static func pseudolocalize(message: StringName
) -> StringName Returns the pseudolocalized string based on the
message
passed in.static func reloadPseudolocalization(
) Reparses the pseudolocalization options and reloads the translation.
static func removeTranslation(Translation?
) Removes the given translation from the server.
static func setLocale(String
) Sets the locale of the project. The
locale
string will be standardized to match known locales (e.g.en-US
would be matched toen_US
).static func standardizeLocale(String
) -> String Returns a
locale
string standardized to match known locales (e.g.en-US
would be matched toen_US
).static func translate(message: StringName, context: StringName
) -> StringName Returns the current locale’s translation for the given message (key) and context.
static func translatePlural(message: StringName, pluralMessage: StringName, n: Int32, context: StringName
) -> StringName Returns the current locale’s translation for the given message (key), plural message and context.
class var godotClassName: StringName