RegionUtils
This is a helper class to handle challenges with presenting information in the user’s region.
Methods
Type |
Name |
|---|---|
Localizes a raw date string which is in ISO8601 format.
# User prefers DD/MM/YYYY
RegionUtils.localize_date("19870102T152741") # Returns "02/01/1987 15:27:41"
Globalizes a previously localized date with localize_date back to a global ISO8601 format. source_format can be specified to tell in which format the string is (one of date_format), otherwise leave it empty to use the current user’s region.
# User prefers DD/MM/YYYY
RegionUtils.globalize_date_str("02/01/1987 15:27:41") # Returns "19870102T152741"
String globalize_date_dict (date_dict: Dictionary, source_format: String =
"")
Globalizes a date dictionary coming from Godot back to a global ISO8601 format. source_format can be specified to tell in which format the string is (one of date_format), otherwise leave it empty to use the current user’s region.
# User prefers DD/MM/YYYY
RegionUtils.globalize_date_dict({
"year": 1987, "month": 1,
"day": 2, "hour": 15,
"minute": 27, "second": 41
}) # Returns "19870102T152741"
Localizes an age rating string to the user’s preferred age rating system. This returns a Control depicting that information which you should add in your theme’s scene tree.
# User prefers PEGI
RegionUtils.localize_age_rating("2/3/4") # Returns a Control with the PEGI 12 rating icon
int localize_age_rating_idx ()
Returns the internal index for age rating strings (e.g. "0/3/2"). This is useful if you want to use the age rating string in your own code.
# User prefers PEGI
RegionUtils.localize_age_rating_idx() # Returns idx 1
Localizes a short system name to the user’s preferred system name.
# User prefers "Sega Megadrive"
RegionUtils.localize_system_name("genesis") # Returns "megadrive"