class RunLoop::L10N
Constants
- LANG_CODE_TO_LANG_NAME_MAP
- UIKIT_AXBUNDLE_PATH_CORE_SIM
- UIKIT_AXBUNDLE_PATH_CORE_SIM_XCODE_9
Attributes
xcode[R]
@!visibility private
Public Instance Methods
inspect()
click to toggle source
@!visibility private
# File lib/run_loop/l10n.rb, line 39 def inspect to_s end
is_full_name?(two_letter_country_code)
click to toggle source
# File lib/run_loop/l10n.rb, line 81 def is_full_name?(two_letter_country_code) LANG_CODE_TO_LANG_NAME_MAP.has_key?(two_letter_country_code) end
key_name_lookup_table(lang_dir_name)
click to toggle source
# File lib/run_loop/l10n.rb, line 85 def key_name_lookup_table(lang_dir_name) path = File.join(uikit_bundle_l10n_path, lang_dir_name, 'Accessibility.strings') JSON.parse(`plutil -convert json #{path} -o -`) end
lang_dir(localized_lang)
click to toggle source
maps the ios keyboard localization to a language directory where we can find a key-code -> localized-label mapping
# File lib/run_loop/l10n.rb, line 45 def lang_dir(localized_lang) l10n_path = uikit_bundle_l10n_path ## 2 char + _ + sub localization # en_GB.lproj lang_dir_name = "#{localized_lang}.lproj".sub('-','_') if File.exists?(File.join(l10n_path, lang_dir_name)) return lang_dir_name end # 2 char iso language code # vi.lproj two_char_country_code = localized_lang.split('-')[0] lang_dir_name = "#{two_char_country_code}.lproj" if File.exists?(File.join(l10n_path, lang_dir_name)) return lang_dir_name end # Full name # e.g. Dutch.lproj lang_dir_name = "#{LANG_CODE_TO_LANG_NAME_MAP[two_char_country_code]}.lproj" if is_full_name?(two_char_country_code) && File.exists?(File.join(l10n_path, lang_dir_name)) return lang_dir_name end nil end
lookup_localization_name(key_code, localized_lang)
click to toggle source
Find the localized name for a given key_code
@example
lookup_localization_name('delete.key', 'da') => 'Slet'
@param [String] key_code the localization signifier, e.g. ‘delete.key’ @param [String] localized_lang an iso language code returned by calabash ios server
@return [String] the localized name
# File lib/run_loop/l10n.rb, line 13 def lookup_localization_name(key_code, localized_lang) lookup_table_dir = lang_dir(localized_lang) return nil unless lookup_table_dir key_name_lookup_table(lookup_table_dir)[key_code] end
to_s()
click to toggle source
@!visibility private
# File lib/run_loop/l10n.rb, line 34 def to_s "#<L10N #{uikit_bundle_l10n_path}>" end
uikit_bundle_l10n_path()
click to toggle source
# File lib/run_loop/l10n.rb, line 73 def uikit_bundle_l10n_path if xcode.version_gte_90? File.join(xcode.core_simulator_dir, UIKIT_AXBUNDLE_PATH_CORE_SIM_XCODE_9) else File.join(xcode.developer_dir, UIKIT_AXBUNDLE_PATH_CORE_SIM) end end