1
0
Fork 0
forked from glenux/mfm

feat: add basic support for i18n

This commit is contained in:
Glenn Y. Rolland 2023-11-18 19:58:48 +01:00
parent 47c9dbcd89
commit 24f7927ac0
7 changed files with 44 additions and 2 deletions

5
data/locales/en.yaml Normal file
View file

@ -0,0 +1,5 @@
---
en:
cli:
banner: "Usage: %{program_name} [options]\n\nGlobal options"
#

5
data/locales/fr.yaml Normal file
View file

@ -0,0 +1,5 @@
---
fr:
cli:
banner: "Usage: %{program_name} [options]\n\nOptions globales"
#

View file

@ -1,6 +1,18 @@
---
version: 2.0
shards:
baked_file_system:
git: https://github.com/schovi/baked_file_system.git
version: 0.10.0
crinja:
git: https://github.com/straight-shoota/crinja.git
version: 0.8.1
i18n:
git: https://github.com/crystal-i18n/i18n.git
version: 0.2.1
shellwords:
git: https://github.com/sztheory/shellwords-crystal.git
version: 0.1.0

View file

@ -20,6 +20,13 @@ targets:
dependencies:
shellwords:
github: szTheory/shellwords-crystal
version: 0.1.0
baked_file_system:
github: schovi/baked_file_system
version: 0.10.0
i18n:
github: crystal-i18n/i18n
version: 0.2.1
# dependencies:
# pg:

View file

@ -3,6 +3,7 @@
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
require "i18n"
require "option_parser"
require "./config"
require "./fzf"
@ -16,6 +17,10 @@ module GX
def initialize()
# Main execution starts here
I18n.config.loaders << I18n::Loader::YAML.embed("data/locales")
I18n.config.default_locale = :en
I18n.activate(:fr) ## FIXME: load from environment
I18n.init
@config = Config.new
## FIXME: check that FZF is installed
@ -26,7 +31,7 @@ module GX
add_args = { name: "", path: "" }
delete_args = { name: "" }
pparser = OptionParser.new do |parser|
parser.banner = "Usage: #{PROGRAM_NAME} [options]\n\nGlobal options"
parser.banner = I18n.t("cli.banner", program_name: PROGRAM_NAME)
parser.on("-c", "--config FILE", "Set configuration file") do |path|
@config.path = path

7
src/file_storage.cr Normal file
View file

@ -0,0 +1,7 @@
require "baked_file_system"
class FileStorage
extend BakedFileSystem
bake_folder "../data"
end

View file

@ -8,6 +8,7 @@ require "colorize"
require "json"
require "./filesystems/gocryptfs"
require "./file_storage"
require "./config"
require "./cli"