Class: Uniword::Docx::LocaleProfile
- Inherits:
-
Object
- Object
- Uniword::Docx::LocaleProfile
- Defined in:
- lib/uniword/docx/profile.rb
Overview
Locale profile: language → lang tags, separators, East Asian fonts.
Defines language-specific settings for DOCX generation. Loaded from config/locale_profiles.yml.
Constant Summary collapse
- CONFIG_DIR =
File.join(__dir__, "../../../config")
Instance Attribute Summary collapse
-
#bidi_lang ⇒ Object
readonly
Returns the value of attribute bidi_lang.
-
#decimal_symbol ⇒ Object
readonly
Returns the value of attribute decimal_symbol.
-
#east_asia_lang ⇒ Object
readonly
Returns the value of attribute east_asia_lang.
-
#east_asian_font ⇒ Object
readonly
Returns the value of attribute east_asian_font.
-
#east_asian_light_font ⇒ Object
readonly
Returns the value of attribute east_asian_light_font.
-
#lang ⇒ Object
readonly
Returns the value of attribute lang.
-
#list_separator ⇒ Object
readonly
Returns the value of attribute list_separator.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
Class Method Summary collapse
-
.available_locales ⇒ Object
List all available locales.
-
.from_locale(locale_code) ⇒ Object
Load from config/locale_profiles.yml.
Instance Method Summary collapse
-
#initialize(locale:, lang:, east_asia_lang:, bidi_lang:, decimal_symbol:, list_separator:, east_asian_font: nil, east_asian_light_font: nil) ⇒ LocaleProfile
constructor
A new instance of LocaleProfile.
Constructor Details
#initialize(locale:, lang:, east_asia_lang:, bidi_lang:, decimal_symbol:, list_separator:, east_asian_font: nil, east_asian_light_font: nil) ⇒ LocaleProfile
Returns a new instance of LocaleProfile.
191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/uniword/docx/profile.rb', line 191 def initialize(locale:, lang:, east_asia_lang:, bidi_lang:, decimal_symbol:, list_separator:, east_asian_font: nil, east_asian_light_font: nil) @locale = locale @lang = lang @east_asia_lang = east_asia_lang @bidi_lang = bidi_lang @decimal_symbol = decimal_symbol @list_separator = list_separator @east_asian_font = east_asian_font @east_asian_light_font = east_asian_light_font end |
Instance Attribute Details
#bidi_lang ⇒ Object (readonly)
Returns the value of attribute bidi_lang.
187 188 189 |
# File 'lib/uniword/docx/profile.rb', line 187 def bidi_lang @bidi_lang end |
#decimal_symbol ⇒ Object (readonly)
Returns the value of attribute decimal_symbol.
187 188 189 |
# File 'lib/uniword/docx/profile.rb', line 187 def decimal_symbol @decimal_symbol end |
#east_asia_lang ⇒ Object (readonly)
Returns the value of attribute east_asia_lang.
187 188 189 |
# File 'lib/uniword/docx/profile.rb', line 187 def east_asia_lang @east_asia_lang end |
#east_asian_font ⇒ Object (readonly)
Returns the value of attribute east_asian_font.
187 188 189 |
# File 'lib/uniword/docx/profile.rb', line 187 def east_asian_font @east_asian_font end |
#east_asian_light_font ⇒ Object (readonly)
Returns the value of attribute east_asian_light_font.
187 188 189 |
# File 'lib/uniword/docx/profile.rb', line 187 def east_asian_light_font @east_asian_light_font end |
#lang ⇒ Object (readonly)
Returns the value of attribute lang.
187 188 189 |
# File 'lib/uniword/docx/profile.rb', line 187 def lang @lang end |
#list_separator ⇒ Object (readonly)
Returns the value of attribute list_separator.
187 188 189 |
# File 'lib/uniword/docx/profile.rb', line 187 def list_separator @list_separator end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
187 188 189 |
# File 'lib/uniword/docx/profile.rb', line 187 def locale @locale end |
Class Method Details
.available_locales ⇒ Object
List all available locales
220 221 222 223 |
# File 'lib/uniword/docx/profile.rb', line 220 def self.available_locales path = File.join(CONFIG_DIR, "locale_profiles.yml") YAML.load_file(path)["locales"].keys.sort end |
.from_locale(locale_code) ⇒ Object
Load from config/locale_profiles.yml
205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/uniword/docx/profile.rb', line 205 def self.from_locale(locale_code) path = File.join(CONFIG_DIR, "locale_profiles.yml") all = YAML.load_file(path)["locales"] unless all.key?(locale_code) raise ArgumentError, "Locale '#{locale_code}' not found. " \ "Available: #{all.keys.join(', ')}" end data = all[locale_code] new(locale: locale_code, **data.transform_keys(&:to_sym)) end |