1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-30 08:53:05 +00:00

translate in french and in english

This commit is contained in:
nishiki 2014-01-10 22:36:51 +01:00
parent 3662bcb251
commit 8530f61b76
4 changed files with 50 additions and 7 deletions

View file

@ -111,6 +111,21 @@ en:
display: display:
connect: "Connection to:" connect: "Connection to:"
nothing: "Nothing result!" nothing: "Nothing result!"
server:
option:
usage: "Usage"
config: "Specifie the configuration file"
checkconfig: "Check the configuration"
setup: "Setup a new configuration file"
help: "Show this message help"
form:
setup:
title: "Serveur configuration"
host: "IP listen: "
port: "Port listen: "
data_dir: "Data directory: "
timeout: "Timeout to second: "
not_valid: "ERROR: Impossible to write the configuration file!"
formats: formats:
default: ! '%Y-%m-%d' default: ! '%Y-%m-%d'
long: ! '%B %d, %Y' long: ! '%B %d, %Y'

View file

@ -111,6 +111,21 @@ fr:
display: display:
connect: "Connexion à:" connect: "Connexion à:"
nothing: "Aucun résultat!" nothing: "Aucun résultat!"
server:
option:
usage: "Utilisation"
config: "Spécifie le fichier de configuration"
checkconfig: "Vérifie le fichier de configuration"
setup: "Permet de générer un nouveau fichier de configuration"
help: "Affiche ce message d'aide"
form:
setup:
title: "Configuration du serveur"
host: "IP d'écoute: "
port: "Port d'écoute: "
data_dir: "Répertoire des données: "
timeout: "Timeout en seconde: "
not_valid: "ERREUR: Impossible d'écire le fichier de configuration!"
formats: formats:
default: ! '%Y-%m-%d' default: ! '%Y-%m-%d'
long: ! '%B %d, %Y' long: ! '%B %d, %Y'

View file

@ -260,7 +260,6 @@ class Server
# @args: file_config -> the configuration file # @args: file_config -> the configuration file
# @rtrn: true if le config file is create # @rtrn: true if le config file is create
def setup(file_config) def setup(file_config)
puts I18n.t('server.form.setup.title') puts I18n.t('server.form.setup.title')
puts '--------------------' puts '--------------------'
host = ask(I18n.t('server.form.setup.host')).to_s host = ask(I18n.t('server.form.setup.host')).to_s
@ -278,7 +277,7 @@ class Server
file << config.to_yaml file << config.to_yaml
end end
rescue Exception => e rescue Exception => e
@error_msg = "Can't write the config file!\n#{e}" puts "#{I18n.t('server.formsetup.not_valid')}\n#{e}"
return false return false
end end

View file

@ -6,32 +6,46 @@
require 'rubygems' require 'rubygems'
require 'optparse' require 'optparse'
require 'pathname' require 'pathname'
require 'locale'
require 'i18n'
APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath) APP_ROOT = File.dirname(Pathname.new(__FILE__).realpath)
require "#{APP_ROOT}/lib/Server.rb" require "#{APP_ROOT}/lib/Server.rb"
lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
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 = {} options = {}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "Usage: mpw-server -c CONFIG [options]" opts.banner = "#{I18n.t('server.option.usage')}: mpw-server -c CONFIG [options]"
opts.on("-c", "--config CONFIG", "Specifie the configuration file") do |config| opts.on("-c", "--config CONFIG", I18n.t('server.option.config')) do |config|
options[:config] = config options[:config] = config
end end
opts.on("-t", "--check-config", "Check your configuration") do |b| opts.on("-t", "--checkconfig", I18n.t('server.option.checkconfig')) do |b|
options[:checkconfig] = b options[:checkconfig] = b
end end
opts.on("-s", "--setup", "Force a server") do |b| opts.on("-s", "--setup", I18n.t('server.option.setup')) do |b|
options[:setup] = b options[:setup] = b
end end
opts.on("-h", "--help", "Show this message") do |b| opts.on("-h", "--help", I18n.t('server.option.help')) do |b|
puts opts puts opts
exit 0 exit 0
end end
end.parse! end.parse!
if options[:config].nil? || options[:config].empty?
puts "#{I18n.t('server.option.usage')}: mpw-server -c CONFIG [options]"
exit 2
end
server = Server.new server = Server.new
if options[:checkconfig] if options[:checkconfig]