lib/translate_self/translation.rb in translate_self-0.6.0 vs lib/translate_self/translation.rb in translate_self-0.7.0
- old
+ new
@@ -1,13 +1,14 @@
require 'deepl'
# The part where the actual translation happens.
module Translation
+ @@languages = %w[bg cs da de el en es et fi fr hu it ja lt lv nl pl pt ro ru sk sl sv zh].freeze
attr_accessor :language, :to_language
def available_languages
- TranslateSelf::AVAILABLE_LANGUAGES
+ @@languages
end
# Translates self to the desired language. \
# Sample usage:
# hello = 'hello'\
@@ -37,10 +38,10 @@
# 'hello'.translate_to_fi
# # Hei
#
# @param [String] the language to translate to, e.g. "fi"
# @return [String] the contents translated to another language
- %w[bg cs da de el en es et fi fr hu it ja lt lv nl pl pt ro ru sk sl sv zh].each do |lan|
+ @@languages.each do |lan|
define_method("translate_to_#{lan}") do |language = lan|
call_deepl(self, self.language, language)
end
end