1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-23 13:57:52 +00:00

change method for default language

This commit is contained in:
nishiki 2013-12-30 22:14:29 +01:00
parent 787cdf0b50
commit 838e8f7563
4 changed files with 8 additions and 13 deletions

View file

@ -14,6 +14,8 @@ require "#{APP_ROOT}/lib/MPW.rb"
class Cli
# Constructor
# @args: lang -> the operating system language
# config_file -> a specify config file
def initialize(lang, config_file=nil)
@m = MPW.new(config_file)

View file

@ -25,6 +25,7 @@ class MPW
attr_accessor :timeout_pwd
# Constructor
# @args: file_config -> the specify config file
def initialize(file_config=nil)
@error_msg = nil
@file_config = "#{Dir.home()}/.mpw.cfg"
@ -86,12 +87,7 @@ class MPW
return false
end
if !@lang.nil? && !@lang.empty?
if !File.exist?("#{APP_ROOT}/i18n/#{@lang}.yml")
@lang = 'en'
end
I18n.locale = @lang.to_sym
end
I18n.locale = @lang.to_sym
rescue Exception => e
@error_msg = "#{I18n.t('error.config.check')}\n#{e}"

5
mpw
View file

@ -15,10 +15,9 @@ require "#{APP_ROOT}/lib/Cli.rb"
lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
if !File.exist?("#{APP_ROOT}/i18n/#{lang}.yml")
lang = 'en'
end
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.load_path = Dir["#{APP_ROOT}/i18n/*.yml"]
I18n.default_locale = :en
I18n.locale = lang.to_sym
options = {}

View file

@ -14,13 +14,11 @@ require "#{APP_ROOT}/lib/CliSSH.rb"
lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
if !File.exist?("#{APP_ROOT}/i18n/#{lang}.yml")
lang = 'en'
end
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.load_path = Dir["#{APP_ROOT}/i18n/*.yml"]
I18n.default_locale = :en
I18n.locale = lang.to_sym
options = {}
OptionParser.new do |opts|
opts.banner = "#{I18n.t('ssh.option.usage')}: mpw-ssh SEARCH [options]"