2023-10-08 00:16:37 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-10-07 08:21:48 +02:00
|
|
|
module Mixin::T
|
2023-10-07 15:09:53 +02:00
|
|
|
def t(locale, key, local_assigns = {})
|
2024-05-01 03:41:01 +02:00
|
|
|
str = [locale, *key.split(".")].inject(tdata) { _1[_2] }
|
2023-10-07 15:09:53 +02:00
|
|
|
format(str, local_assigns)
|
2023-10-07 08:21:48 +02:00
|
|
|
end
|
|
|
|
|
2024-05-01 03:41:01 +02:00
|
|
|
def tdata
|
2024-05-01 05:59:22 +02:00
|
|
|
@tdata ||= begin
|
|
|
|
path = File.join(Dir.getwd, "src", "json", "t.json")
|
|
|
|
Ryo.from_json_file(path)
|
|
|
|
end
|
2023-10-07 08:21:48 +02:00
|
|
|
end
|
|
|
|
end
|