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:
parent
787cdf0b50
commit
838e8f7563
4 changed files with 8 additions and 13 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
5
mpw
|
@ -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 = {}
|
||||
|
|
6
mpw-ssh
6
mpw-ssh
|
@ -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]"
|
||||
|
|
Loading…
Reference in a new issue