Skip to content

Commit

Permalink
rage: Localize usage and help text
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Jan 8, 2024
1 parent f9087be commit b3de9b9
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 83 deletions.
2 changes: 1 addition & 1 deletion rage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ maintenance = { status = "experimental" }
# rage and rage-keygen dependencies
age = { workspace = true, features = ["armor", "cli-common", "plugin"] }
chrono.workspace = true
clap.workspace = true
clap = { workspace = true, features = ["string", "unstable-styles"] }
console.workspace = true
env_logger.workspace = true
i18n-embed = { workspace = true, features = ["desktop-requester"] }
Expand Down
51 changes: 41 additions & 10 deletions rage/i18n/en-US/rage.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Localization for strings in the rage CLI tools

-age = age
-age-plugin- = age-plugin-
-rage = rage
## CLI flags
Expand All @@ -27,25 +28,45 @@
## Usage

-input = INPUT
-output = OUTPUT
-identity = IDENTITY
-recipient = RECIPIENT
-recipients-file = PATH
usage-header = Usage
usage-header = Usage:
recipient = RECIPIENT
recipients-file = PATH
identity = IDENTITY
plugin-name = PLUGIN-NAME
input = INPUT
output = OUTPUT
args-header = Arguments
help-arg-input = Path to a file to read from.
flags-header = Options
help-flag-help = Print this help message and exit.
help-flag-version = Print version info and exit.
help-flag-encrypt = Encrypt the input (the default).
help-flag-decrypt = Decrypt the input.
help-flag-passphrase = Encrypt with a passphrase instead of recipients.
help-flag-max-work-factor = Maximum work factor to allow for passphrase decryption.
help-flag-armor = Encrypt to a PEM encoded format.
help-flag-recipient = Encrypt to the specified {recipient}. May be repeated.
help-flag-recipients-file = Encrypt to the recipients listed at {recipients-file}. May be repeated.
help-flag-identity = Use the identity file at {identity}. May be repeated.
help-flag-plugin-name = Use {-age-plugin-}{plugin-name} in its default mode as an identity.
help-flag-output = Write the result to the file at path {output}.
rage-after-help =
{-input} defaults to standard input, and {-output} defaults to standard output.
{input} defaults to standard input, and {output} defaults to standard output.
{-recipient} can be:
{recipient} can be:
- An {-age} public key, as generated by {$keygen_name} ("age1...").
- An SSH public key ("ssh-ed25519 AAAA...", "ssh-rsa AAAA...").
{-recipients-file} is a path to a file containing {-age} recipients, one per line
{recipients-file} is a path to a file containing {-age} recipients, one per line
(ignoring "#" prefixed comments and empty lines).
{-identity} is a path to a file with {-age} identities, one per line
{identity} is a path to a file with {-age} identities, one per line
(ignoring "#" prefixed comments and empty lines), or to an SSH key file.
Passphrase-encrypted {-age} identity files can be used as identity files.
Multiple identities may be provided, and any unused ones will be ignored.
Expand All @@ -56,6 +77,8 @@ rage-after-help =
{" "}{$example_b}
{" "}{$example_c}
keygen-help-flag-output = {help-flag-output} Defaults to standard output.
## Formatting

warning-msg = Warning: {$warning}
Expand Down Expand Up @@ -155,6 +178,14 @@ rec-dec-recipient-flag = Did you mean to use {-flag-identity} to specify a priva

-flag-mnt-types = -t/--types
mnt-filename = FILENAME
mnt-mountpoint = MOUNTPOINT
mnt-types = TYPES
help-arg-mnt-filename = The encrypted filesystem to mount.
help-arg-mnt-mountpoint = The directory to mount the filesystem at.
help-arg-mnt-types = Indicates the filesystem type (one of {$types}).
info-decrypting = Decrypting {$filename}
info-mounting-as-fuse = Mounting as FUSE filesystem
Expand Down
22 changes: 12 additions & 10 deletions rage/i18n/es-AR/rage.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Localization for strings in the rage CLI tools

-age = age
-age-plugin- = age-plugin-
-rage = rage
## CLI flags
Expand All @@ -27,25 +28,26 @@
## Usage

-input = INPUT
-output = OUTPUT
-identity = IDENTITY
-recipient = RECIPIENT
-recipients-file = PATH
usage-header = Usage
usage-header = Usage:
recipient = RECIPIENT
recipients-file = PATH
identity = IDENTITY
plugin-name = PLUGIN-NAME
input = INPUT
output = OUTPUT
rage-after-help =
{-input} por defecto a standard input, y {-output} por defecto standard output.
{input} por defecto a standard input, y {output} por defecto standard output.
{-recipient} puede ser:
{recipient} puede ser:
- Una clave pública {-age}, como es generada por {$keygen_name} ("age1...").
- Una clave pública SSH ("ssh-ed25519 AAAA...", "ssh-rsa AAAA...").
{-recipients-file} es una ruta a un archivo que contenga un destinatario {-age} por línea
{recipients-file} es una ruta a un archivo que contenga un destinatario {-age} por línea
(ignorando comentarios con el prefijo "#" y líneas vacías).
{-identity} es una ruta a una archivo con una identidad {-age} por línea
{identity} es una ruta a una archivo con una identidad {-age} por línea
(ignorando comentarios con el prefijo "#" y líneas vacías), o a un archivo
de claves SSH.
Passphrase-encrypted {-age} identity files can be used as identity files.
Expand Down
22 changes: 12 additions & 10 deletions rage/i18n/it/rage.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Localization for strings in the rage CLI tools

-age = age
-age-plugin- = age-plugin-
-rage = rage
## CLI flags
Expand All @@ -27,26 +28,27 @@
## Usage

-input = INPUT
-output = OUTPUT
-identity = IDENTITY
-recipient = RECIPIENT
-recipients-file = PATH
usage-header = Usage
usage-header = Usage:
recipient = RECIPIENT
recipients-file = PATH
identity = IDENTITY
plugin-name = PLUGIN-NAME
input = INPUT
output = OUTPUT
rage-after-help =
{-input} ha come valore predefinito lo standard input, e {-output} ha come
{input} ha come valore predefinito lo standard input, e {output} ha come
valore predefinito lo standard output.
{-recipient} può essere:
{recipient} può essere:
- Una chiave pubblica {-age}, come generata da {$keygen_name} ("age1...").
- Una chiave pubblica SSH ("ssh-ed25519 AAAA...", "ssh-rsa AAAA...").
{-recipients-file} è il percorso ad un file contenente dei destinatari {-age},
{recipients-file} è il percorso ad un file contenente dei destinatari {-age},
uno per riga (ignorando i commenti che iniziano con "#" e le righe vuote).
{-identity} è il percorso ad un file contenente identità {-age}, una per
{identity} è il percorso ad un file contenente identità {-age}, una per
riga (ignorando i commenti che iniziano con "#" e le righe vuote), o ad un
file contenente una chiave SSH.
I file di identità possono essere cifrati con {-age} e una passphrase.
Expand Down
22 changes: 12 additions & 10 deletions rage/i18n/zh-CN/rage.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Localization for strings in the rage CLI tools

-age = age
-age-plugin- = age-plugin-
-rage = rage
## CLI flags
Expand All @@ -27,25 +28,26 @@
## Usage

-input = INPUT
-output = OUTPUT
-identity = IDENTITY
-recipient = RECIPIENT
-recipients-file = PATH
usage-header = Usage
usage-header = Usage:
recipient = RECIPIENT
recipients-file = PATH
identity = IDENTITY
plugin-name = PLUGIN-NAME
input = INPUT
output = OUTPUT
rage-after-help =
{-input} 默认为标准输入 (stdin), 而 {-output} 默认为标准输出 (stdout) 。
{input} 默认为标准输入 (stdin), 而 {output} 默认为标准输出 (stdout) 。
{-recipient} 可为:
{recipient} 可为:
- 一把以 {$keygen_name} 生成的 {-age} 公钥 ("age1...")。
- 一把 SSH 公钥 ("ssh-ed25519 AAAA...", "ssh-rsa AAAA...")。
{-recipients-file} 是一个文件路径。该文件应含有 {-age} 接收方, 每行一个
{recipients-file} 是一个文件路径。该文件应含有 {-age} 接收方, 每行一个
(前缀为 "#" 的注释以及空行将被忽略)。
{-identity} 是一个文件路径。该文件或含 {-age} 身份, 每行一个(前缀为 "#" 的注释以及空行将被忽略),
{identity} 是一个文件路径。该文件或含 {-age} 身份, 每行一个(前缀为 "#" 的注释以及空行将被忽略),
亦或为 SSH 密钥文件。
Passphrase-encrypted {-age} identity files can be used as identity files.
您可提供多份身份, 未使用的身份将被忽略。
Expand Down
22 changes: 12 additions & 10 deletions rage/i18n/zh-TW/rage.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Localization for strings in the rage CLI tools

-age = age
-age-plugin- = age-plugin-
-rage = rage
## CLI flags
Expand All @@ -27,25 +28,26 @@
## Usage

-input = INPUT
-output = OUTPUT
-identity = IDENTITY
-recipient = RECIPIENT
-recipients-file = PATH
usage-header = Usage
usage-header = Usage:
recipient = RECIPIENT
recipients-file = PATH
identity = IDENTITY
plugin-name = PLUGIN-NAME
input = INPUT
output = OUTPUT
rage-after-help =
{-input} 默認為標準輸入 (stdin), 而 {-output} 默認為標準輸出 (stdout) 。
{input} 默認為標準輸入 (stdin), 而 {output} 默認為標準輸出 (stdout) 。
{-recipient} 可為:
{recipient} 可為:
- 一把以 {$keygen_name} 生成的 {-age} 公鑰 ("age1...")。
- 一把 SSH 公鑰 ("ssh-ed25519 AAAA...", "ssh-rsa AAAA...")。
{-recipients-file} 是一個文件路徑。該文件應含有 {-age} 接收方, 每行一個
{recipients-file} 是一個文件路徑。該文件應含有 {-age} 接收方, 每行一個
(前綴為 "#" 的注釋以及空行將被忽略)。
{-identity} 是一個文件路徑。該文件或含 {-age} 身份, 每行一個(前綴為 "#" 的注釋以及空行將被忽略),
{identity} 是一個文件路徑。該文件或含 {-age} 身份, 每行一個(前綴為 "#" 的注釋以及空行將被忽略),
亦或為 SSH 密鑰文件。
Passphrase-encrypted {-age} identity files can be used as identity files.
您可提供多份身份, 未使用的身份將被忽略。
Expand Down
19 changes: 15 additions & 4 deletions rage/src/bin/rage-keygen/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![forbid(unsafe_code)]

use age::{cli_common::file_io, secrecy::ExposeSecret};
use clap::{ArgAction, Parser};
use clap::{builder::Styles, ArgAction, Parser};
use i18n_embed::{
fluent::{fluent_language_loader, FluentLanguageLoader},
DesktopLanguageRequester,
Expand Down Expand Up @@ -35,19 +35,30 @@ macro_rules! fl {
#[command(display_name = "rage-keygen")]
#[command(name = "rage-keygen")]
#[command(version)]
#[command(help_template = format!("\
{{before-help}}{{about-with-newline}}
{}{}:{} {{usage}}
{{all-args}}{{after-help}}\
",
Styles::default().get_usage().render(),
fl!("usage-header"),
Styles::default().get_usage().render_reset()))]
#[command(next_help_heading = fl!("flags-header"))]
#[command(disable_help_flag(true))]
#[command(disable_version_flag(true))]
struct AgeOptions {
#[arg(action = ArgAction::Help, short, long)]
#[arg(help = "Print this help message and exit.")]
#[arg(help = fl!("help-flag-help"))]
help: Option<bool>,

#[arg(action = ArgAction::Version, short = 'V', long)]
#[arg(help = "Print version info and exit.")]
#[arg(help = fl!("help-flag-version"))]
version: Option<bool>,

#[arg(short, long)]
#[arg(help = "Write the result to the file at path OUTPUT. Defaults to standard output.")]
#[arg(value_name = fl!("output"))]
#[arg(help = fl!("keygen-help-flag-output"))]
output: Option<String>,
}

Expand Down
32 changes: 24 additions & 8 deletions rage/src/bin/rage-mount/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use age::{
cli_common::{read_identities, read_secret},
stream::StreamReader,
};
use clap::{ArgAction, CommandFactory, Parser};
use clap::{builder::Styles, ArgAction, CommandFactory, Parser};
use fuse_mt::FilesystemMT;
use fuser::MountOption;
use i18n_embed::{
Expand Down Expand Up @@ -129,33 +129,49 @@ impl fmt::Debug for Error {
#[command(display_name = "rage-mount")]
#[command(name = "rage-mount")]
#[command(version)]
#[command(help_template = format!("\
{{before-help}}{{about-with-newline}}
{}{}:{} {{usage}}
{{all-args}}{{after-help}}\
",
Styles::default().get_usage().render(),
fl!("usage-header"),
Styles::default().get_usage().render_reset()))]
#[command(next_help_heading = fl!("flags-header"))]
#[command(disable_help_flag(true))]
#[command(disable_version_flag(true))]
struct AgeMountOptions {
#[arg(help = "The encrypted filesystem to mount.")]
#[arg(help_heading = fl!("args-header"))]
#[arg(value_name = fl!("mnt-filename"))]
#[arg(help = fl!("help-arg-mnt-filename"))]
filename: String,

#[arg(help = "The directory to mount the filesystem at.")]
#[arg(help_heading = fl!("args-header"))]
#[arg(value_name = fl!("mnt-mountpoint"))]
#[arg(help = fl!("help-arg-mnt-mountpoint"))]
mountpoint: String,

#[arg(action = ArgAction::Help, short, long)]
#[arg(help = "Print this help message and exit.")]
#[arg(help = fl!("help-flag-help"))]
help: Option<bool>,

#[arg(action = ArgAction::Version, short = 'V', long)]
#[arg(help = "Print version info and exit.")]
#[arg(help = fl!("help-flag-version"))]
version: Option<bool>,

#[arg(short, long)]
#[arg(help = "Indicates the filesystem type (one of \"tar\", \"zip\").")]
#[arg(value_name = fl!("mnt-types"))]
#[arg(help = fl!("help-arg-mnt-types", types = "\"tar\", \"zip\""))]
types: String,

#[arg(long, value_name = "WF")]
#[arg(help = "Maximum work factor to allow for passphrase decryption.")]
#[arg(help = fl!("help-flag-max-work-factor"))]
max_work_factor: Option<u8>,

#[arg(short, long)]
#[arg(help = "Use the private key file at IDENTITY. May be repeated.")]
#[arg(value_name = fl!("identity"))]
#[arg(help = fl!("help-flag-identity"))]
identity: Vec<String>,
}

Expand Down
Loading

0 comments on commit b3de9b9

Please sign in to comment.