Skip to content

Commit d9c655b

Browse files
committed
add support for xtr's add-location option, v0.1.5
- now requires xtr v0.1.5 - bump i18n-config to v0.2.2 - bump i18n-build to v0.3.0
1 parent cb1b518 commit d9c655b

10 files changed

Lines changed: 67 additions & 18 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "MIT"
88
name = "cargo-i18n"
99
readme = "README.md"
1010
repository = "https://github.com/kellpossible/cargo-i18n"
11-
version = "0.1.4"
11+
version = "0.1.5"
1212

1313
[badges]
1414
maintenance = { status = "actively-developed" }
@@ -17,7 +17,7 @@ maintenance = { status = "actively-developed" }
1717

1818
[dependencies]
1919
i18n-embed = { version = "0.3", path = "./i18n-embed", features = ["desktop-requester"] }
20-
i18n-build = { version = "0.2", path = "./i18n-build", features = ["localize"] }
20+
i18n-build = { version = "0.3", path = "./i18n-build", features = ["localize"] }
2121
i18n-config = { version = "0.2", path = "./i18n-config" }
2222
anyhow = "1.0"
2323
gettext = "0.4"

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ extract_to_parent = false
188188
# is false.
189189
collate_extracted_subcrates = false
190190

191+
# (Optional) How much message location information to include in the output.
192+
# If the type is ‘full’ (the default), it generates the lines with both file
193+
# name and line number: ‘#: filename:line’. If it is ‘file’, the line number
194+
# part is omitted: ‘#: filename’. If it is ‘never’, nothing is generated.
195+
# [possible values: full, file, never].
196+
add_location = "full"
197+
191198
# (Optional) Whether or not to perform string extraction using the `xtr` tool.
192199
xtr = true
193200

i18n-build/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog for `i18n-build`
22

3+
## v0.3.0
4+
5+
+ Add support for `xtr` `add-location` option.
6+
+ Requires `xtr` version `0.1.5`.
7+
+ Suppress progress output for `msgmerge` using `--silent`.
8+
39
## v0.2.1
410

511
+ Updated link to this changelog in the crate README.

i18n-build/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "MIT"
88
name = "i18n-build"
99
readme = "README.md"
1010
repository = "https://github.com/kellpossible/cargo-i18n/tree/master/i18n-build"
11-
version = "0.2.1"
11+
version = "0.3.0"
1212

1313
[package.metadata.docs.rs]
1414
all-features = true

i18n-build/i18n/po/ru/i18n_build.po

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@ msgid ""
22
msgstr ""
33
"Project-Id-Version: i18n-build\n"
44
"Report-Msgid-Bugs-To: \n"
5-
"POT-Creation-Date: 2020-04-10 12:18+0000\n"
5+
"POT-Creation-Date: 2020-04-17 08:38+0000\n"
66
"Language: ru\n"
77
"MIME-Version: 1.0\n"
88
"Content-Type: text/plain; charset=UTF-8\n"
99
"Content-Transfer-Encoding: 8bit\n"
1010
"X-Generator: POEditor.com\n"
1111

1212
#. {0} is the file path, {1} is the item which it is for, {2} is the type of item (file, directory, etc)
13-
#: i18n-build/src/error.rs:135
13+
#: i18n-build/src/error.rs:140
1414
msgid "The path (\"{0}\") for {1} {2} does not have valid a utf-8 encoding."
1515
msgstr "Путь (\"{0}\") для {1} {2} не имеeт допустимой кодировки utf-8."
1616

17-
#: i18n-build/src/error.rs:142
17+
#: i18n-build/src/error.rs:147
1818
msgid "The path \"{0}\" does not exist on the filesystem."
1919
msgstr "Путь \"{0}\" не существует в файловой системе."
2020

2121
#. {0} can be either "file", or "directory", or "symlink"
2222
#. {1} is a file path
2323
#. {2} is more detailed information about the error
2424
#. Example: Cannot create the file "i18n/ru/something.pot" because "some error occurred"
25-
#: i18n-build/src/error.rs:150
25+
#: i18n-build/src/error.rs:155
2626
msgid "Cannot create the {0} \"{1}\" because: \"{2}\"."
2727
msgstr "Не удалось создать {0} \"{1}\" так как: \"{2}\"."
2828

2929
#. {0} can be either "file", or "directory", or "symlink"
3030
#. {1} is a file path
3131
#. {2} is more detailed information about the error
3232
#. Example: Cannot delete the file "i18n/ru/something.pot" because "some error occurred"
33-
#: i18n-build/src/error.rs:160
33+
#: i18n-build/src/error.rs:165
3434
msgid "Cannot delete the {0} \"{1}\" because: \"{2}\"."
3535
msgstr "Не удалось удалить {0} \"{1}\" так как: \"{2}\"."
3636

@@ -39,34 +39,34 @@ msgstr "Не удалось удалить {0} \"{1}\" так как: \"{2}\"."
3939
#. {2} is the new file name
4040
#. {3} is more detailed information about the error
4141
#. Example: Cannot rename the file "old.pot" to "new.pot" because "some error occurred"
42-
#: i18n-build/src/error.rs:171
42+
#: i18n-build/src/error.rs:176
4343
msgid "Cannot rename the {0} \"{1}\" to \"{2}\" because {3}."
4444
msgstr "Не удалось переименовать {0} \"{1}\" в \"{2}\" так как {3}."
4545

4646
#. {0} is a directory path
4747
#. {1} is the name of the parent directory
4848
#. {2} is the expected parent of the directory in {0}
4949
#. Example: The path "i18n/src/po" is not inside the "src" directory: "i18n/src"."
50-
#: i18n-build/src/error.rs:182
50+
#: i18n-build/src/error.rs:187
5151
msgid "The path \"{0}\" is not inside the \"{1}\" directory: \"{2}\"."
5252
msgstr "Путь \"{0}\" не находится \"{1}\" в каталоге: \"{2}\"."
5353

54-
#: i18n-build/src/gettext_impl/mod.rs:213
54+
#: i18n-build/src/gettext_impl/mod.rs:215
5555
msgid "There was a problem executing the \"{0}\" command"
5656
msgstr "Произошла ошибка при выполнении команды \"{0}\"."
5757

58-
#: i18n-build/src/gettext_impl/mod.rs:438
58+
#: i18n-build/src/gettext_impl/mod.rs:442
5959
msgid "There was a problem parsing one of the subcrates: \"{0}\"."
6060
msgstr "При анализе одного из подкрэйтора произошла ошибка: \"{0}\"."
6161

62-
#: i18n-build/src/util.rs:15
62+
#: i18n-build/src/util.rs:17
6363
msgid "The \"{0}\" command was unable to start."
6464
msgstr "Команду \"{0}\" не удалось запустить."
6565

66-
#: i18n-build/src/util.rs:19
66+
#: i18n-build/src/util.rs:21
6767
msgid "The \"{0}\" command had a problem waiting for output."
6868
msgstr "У команды \"{0}\" возникла проблема при ожидании вывода."
6969

70-
#: i18n-build/src/util.rs:27
70+
#: i18n-build/src/util.rs:29
7171
msgid "The \"{0}\" command reported that it was unsuccessful."
7272
msgstr "Команда \"{0}\" сообщила что она не удалась."

i18n-build/src/gettext_impl/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ pub fn run_xtr(
120120
crt.version.as_str(),
121121
"--default-domain",
122122
crt.module_name().as_str(),
123+
"--add-location",
124+
gettext_config.add_location.to_str(),
123125
"-o",
124126
pot_file_path.to_str().ok_or(PathError::not_valid_utf8(
125127
pot_file_path.clone(),
@@ -315,6 +317,7 @@ pub fn run_msgmerge(
315317

316318
let mut msgmerge = Command::new(msgmerge_command_name);
317319
msgmerge.args(&[
320+
"--silent",
318321
"--backup=none",
319322
"--update",
320323
po_file_path.to_str().ok_or(PathError::not_valid_utf8(

i18n-config/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog for `i18n-config`
22

3+
## v0.2.2
4+
5+
+ Add support for `xtr` `add-location` option.
6+
37
## v0.2.1
48

59
+ Updated link to this changelog in the crate README.

i18n-config/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "MIT"
88
name = "i18n-config"
99
readme = "README.md"
1010
repository = "https://github.com/kellpossible/cargo-i18n/tree/master/i18n-config"
11-
version = "0.2.1"
11+
version = "0.2.2"
1212

1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

i18n-config/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,28 @@ impl I18nConfig {
359359
}
360360
}
361361

362+
#[derive(Deserialize, Debug, Clone)]
363+
#[serde(rename_all = "lowercase")]
364+
pub enum GettextAddLocation {
365+
Full,
366+
File,
367+
Never,
368+
}
369+
370+
impl GettextAddLocation {
371+
pub fn to_str(&self) -> &str {
372+
match self {
373+
GettextAddLocation::Full => "full",
374+
GettextAddLocation::File => "file",
375+
GettextAddLocation::Never => "never",
376+
}
377+
}
378+
}
379+
380+
impl Default for GettextAddLocation {
381+
fn default() -> Self { GettextAddLocation::Full }
382+
}
383+
362384
/// The data structure representing what is stored (and possible to
363385
/// store) within the `gettext` subsection of a `i18n.toml` file.
364386
#[derive(Deserialize, Debug, Clone)]
@@ -389,6 +411,13 @@ pub struct GettextConfig {
389411
pub msgid_bugs_address: Option<String>,
390412
/// Whether or not to perform string extraction using the `xtr` command.
391413
pub xtr: Option<bool>,
414+
/// Generate ‘#: filename:line’ lines (default) in the pot files when
415+
/// running the `xtr` command. If the type is ‘full’ (the default),
416+
/// it generates the lines with both file name and line number.
417+
/// If it is ‘file’, the line number part is omitted. If it is ‘never’,
418+
/// nothing is generated. [possible values: full, file, never].
419+
#[serde(default)]
420+
pub add_location: GettextAddLocation,
392421
/// Path to where the pot files will be written to by the `xtr`
393422
/// command, and were they will be read from by `msginit` and
394423
/// `msgmerge`.

0 commit comments

Comments
 (0)