today_ai_weather/config/initializers/locale.rb
songtianlun bd04bb63a1 feat: add support for multiple languages
- Update available locales to include Bengali, Hindi, Urdu, and Arabic
- Add new locale files for each language with translations for UI elements
- Ensure the application can now support a wider audience by providing
  localized content

This change enhances the application's accessibility and usability for
users who speak these languages, allowing for a more inclusive user
experience. The new translations cover key UI components and messages,
ensuring that users can interact with the application in their native
languages.
2025-02-24 17:04:23 +08:00

20 lines
699 B
Ruby

# config/initializers/locale.rb
require "i18n/backend/fallbacks"
# Where the I18n library should search for translation files
I18n.load_path += Dir[Rails.root.join("config", "locales", "*.{rb,yml}")]
# Permitted locales available for the application
I18n.available_locales = [ :en, :"zh-CN", :ja, :ko, :"pt-BR", :hr, :fa, :de, :es, :fr, :it, :tr, :ru, :uk, :pl, :bn, :hi, :ur, :ar ]
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
# I18n::Backend::Simple.include I18n::Backend::Fallbacks
# I18n.fallbacks[:en]
I18n.fallbacks = I18n::Locale::Fallbacks.new(
en: [ :en ],
'zh-CN': [ :zh, :zh_cn, :en ]
)
# Set default locale to something other than :en
I18n.default_locale = :en