1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-27 07:33:05 +00:00

fix I18n.enforce_available_locales

This commit is contained in:
nishiki 2014-02-01 20:17:55 +01:00
parent 63af86e7d4
commit b1c281f318
3 changed files with 50 additions and 1 deletions

16
mpw
View file

@ -13,13 +13,25 @@ APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath)
require "#{APP_ROOT}/MPW/UI/Cli"
require "#{APP_ROOT}/MPW/Config"
# --------------------------------------------------------- #
# Set local
# --------------------------------------------------------- #
lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
if defined? I18n.enforce_available_locales
I18n.enforce_available_locales = true
end
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.load_path = Dir["#{APP_ROOT}/i18n/cli/*.yml"]
I18n.default_locale = :en
I18n.locale = lang.to_sym
# --------------------------------------------------------- #
# Options
# --------------------------------------------------------- #
options = {}
options[:force] = false
options[:format] = false
@ -93,6 +105,10 @@ OptionParser.new do |opts|
end
end.parse!
# --------------------------------------------------------- #
# Main
# --------------------------------------------------------- #
config = MPW::Config.new(options[:config])
check_error = config.checkconfig()

View file

@ -12,13 +12,25 @@ require 'i18n'
APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath)
require "#{APP_ROOT}/lib/Server.rb"
# --------------------------------------------------------- #
# Set local
# --------------------------------------------------------- #
lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
if defined? I18n.enforce_available_locales
I18n.enforce_available_locales = true
end
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.load_path = Dir["#{APP_ROOT}/i18n/server/*.yml"]
I18n.default_locale = :en
I18n.locale = lang.to_sym
# --------------------------------------------------------- #
# Options
# --------------------------------------------------------- #
options = {}
OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw-server -c CONFIG [options]"
@ -41,6 +53,10 @@ OptionParser.new do |opts|
end
end.parse!
# --------------------------------------------------------- #
# Main
# --------------------------------------------------------- #
if options[:config].nil? || options[:config].empty?
puts "#{I18n.t('option.usage')}: mpw-server -c CONFIG [options]"
exit 2
@ -54,8 +70,9 @@ elsif options[:setup]
server.setup(options[:config])
else
if server.checkconfig(options[:config])
server.start()
server.start
end
end
server = nil
exit 0

16
mpw-ssh
View file

@ -15,11 +15,23 @@ require "#{APP_ROOT}/MPW/Config"
lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
# --------------------------------------------------------- #
# Set local
# --------------------------------------------------------- #
if defined? I18n.enforce_available_locales
I18n.enforce_available_locales = true
end
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.load_path = Dir["#{APP_ROOT}/i18n/cli/*.yml"]
I18n.default_locale = :en
I18n.locale = lang.to_sym
# --------------------------------------------------------- #
# Options
# --------------------------------------------------------- #
options = {}
OptionParser.new do |opts|
opts.banner = "#{I18n.t('ssh.option.usage')}: mpw-ssh SEARCH [options]"
@ -46,6 +58,10 @@ OptionParser.new do |opts|
end
end.parse!
# --------------------------------------------------------- #
# Main
# --------------------------------------------------------- #
config = MPW::Config.new(options[:config])
check_error = config.checkconfig()