File: ideal.rb

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

require_relative 'base'

module FastestGettext
  def set_domain(folder, domain, locale)
    @data = {}
    require 'fast_gettext/vendor/mofile'
    FastGettext::GetText::MOFile.open(File.join(folder, locale, 'LC_MESSAGES', "#{domain}.mo"), "UTF-8").each { |k, v| @data[k] = v }
  end

  def _(word)
    @data[word]
  end
end

include FastestGettext # rubocop:disable Style/MixinUsage
set_domain(locale_folder('test'), 'test', 'de')
puts "Ideal: (primitive Hash lookup)"
results_test { _('car') == 'Auto' }

# i cannot add the large file, since its an internal applications mo file
set_domain(locale_folder('large'), 'large', 'de')
results_large