File: translation_repository.rb

package info (click to toggle)
ruby-fast-gettext 4.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 676 kB
  • sloc: ruby: 3,209; makefile: 4
file content (16 lines) | stat: -rw-r--r-- 519 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

module FastGettext
  # Responsibility:
  #  - decide which repository to choose from given input
  module TranslationRepository
    def self.build(name, options)
      type = options[:type] || :mo
      class_name = type.to_s.split('_').map(&:capitalize).join
      unless FastGettext::TranslationRepository.constants.map(&:to_s).include?(class_name)
        require "fast_gettext/translation_repository/#{type}"
      end
      const_get(class_name).new(name, options)
    end
  end
end