From 5c9dda45b2aa1f62e78c9b3c30b09ada4c4b782c Mon Sep 17 00:00:00 2001 From: voitau Date: Sat, 4 Apr 2020 18:02:03 -0700 Subject: [PATCH 1/2] Bump the version --- CONTRIBUTING.md | 7 ++++++- README.md | 29 +++++++++++++++-------------- install.sh | 2 +- mdlm.sh | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7263b5d..f094780 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,15 +1,20 @@ +# Contributing + Thank you for your interest in contributing! Any contribution is very welcome, including but not limited to: + * cleaning the Bash code, making it more portable across other shells and standard compliant. * localizing the documentation. * anything what you think is incorrect or missing here. Bug report: + * please submit as an issue and provide steps to reproduce. Coding style: + * please use 2 spaces indentation * split into reasobly small functions -* use local variables \ No newline at end of file +* use local variables diff --git a/README.md b/README.md index fc9183e..4980771 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,10 @@ Minimal reference implenentation of [Markdown Localization Specification](https: To install or update mdlm, you should run the install script. To do that, you may either download and run the script manually, or use the following cURL or Wget command: ```sh -curl -o- https://raw.githubusercontent.com/markdown-localization/mdlm-sh/v0.0.16/install.sh | bash +curl -o- https://raw.githubusercontent.com/markdown-localization/mdlm-sh/v0.0.17/install.sh | bash ``` ```sh -wget -qO- https://raw.githubusercontent.com/markdown-localization/mdlm-sh/v0.0.16/install.sh | bash +wget -qO- https://raw.githubusercontent.com/markdown-localization/mdlm-sh/v0.0.17/install.sh | bash ``` Running either of the above commands downloads a script and runs it. The script copies mdlm script to `~/.mdlm`, and attempts to add the source lines from the snippet below to the correct profile file (`~/.bash_profile`, or `~/.bashrc`). @@ -29,7 +29,7 @@ alias mdlm='$MDLM_DIR/mdlm.sh' ## List all supported locales -``` +```console $ mdlm search aa (Afaraf) - Afar ab (Аҧсуа) - Abkhazian @@ -45,7 +45,7 @@ av (Авар) - Avaric ## List supported locales matching a specific pattern -``` +```console $ mdlm search uz uz (Ўзбек) Uzbek uz-Cyrl (Ўзбек) Uzbek in Cyrillic script @@ -54,12 +54,12 @@ uz-Latn (O‘zbekcha) Uzbek in Latin script ## Add a new locale -``` +```console $ mdlm add eo Creating new localization files for locale - "eo (Esperanto) - Esperanto": -Creating example/README-eo.md. Confirm? [Y/n] +Creating example/README-eo.md. Confirm? [Y/n] - Created. -Creating README-eo.md. Confirm? [Y/n] +Creating README-eo.md. Confirm? [Y/n] - Created. Finished. Total files created: 2 ``` @@ -68,7 +68,7 @@ As a result, new README-eo.md file will be created. Localization switcher header ## Remove a locale -``` +```console $ mdlm rm eo --yes Removing localization files for locale - "eo (Esperanto) - Esperanto": Removing README-eo.md. @@ -78,11 +78,11 @@ Removing example/README-eo.md. Localization files removed. ``` -As a result, README-eo.md will be removed. Localization switcher header will be updated, or removed, if no other localizations available. Optional `--yes` automatically sets yes to all prompts. +As a result, README-eo.md will be removed. Localization switcher header will be updated, or removed, if no other localizations available. Optional `--yes` automatically sets yes to all prompts. ## Check synchronization status -``` +```console $ mdlm status Localization status for all locales. example/README.md (English): @@ -95,10 +95,11 @@ README.md (English): * README-ru.md (Русский) - synced. ``` -### Get synchronization diff +## Get synchronization diff Locale argument is optional. -``` + +```console $ mdlm diff es Localization status for: es (Español) - Spanish. - example/README-es.md (Español) - outdated. @@ -106,7 +107,7 @@ Localization status for: es (Español) - Spanish. < Here is an outdated text of example. --- > Here is a text of example. -> +> ``` # Contributing @@ -115,4 +116,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) # Credits -Special thanks to [nvm-sh/nvm](https://github.com/nvm-sh/nvm) for inpsiration and specifics. \ No newline at end of file +Special thanks to [nvm-sh/nvm](https://github.com/nvm-sh/nvm) for inpsiration and specifics. diff --git a/install.sh b/install.sh index 6320bb9..663db17 100755 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ { # this ensures the entire script is downloaded # -MDLM_VERSION="0.0.16" +MDLM_VERSION="0.0.17" MDLM_REMOTE_FILE="https://raw.githubusercontent.com/markdown-localization/mdlm-sh/v${MDLM_VERSION}/mdlm.sh" mdlm_echo() { diff --git a/mdlm.sh b/mdlm.sh index 8f2e094..bde9abb 100755 --- a/mdlm.sh +++ b/mdlm.sh @@ -8,7 +8,7 @@ # # Functions: # - mdlm_* - custom functions. -MDLM_VERSION="0.0.16" +MDLM_VERSION="0.0.17" DEFAULT_LCM_LOCAL="English" From f927b91ae40dad2d98b5e98d4f02843998160a22 Mon Sep 17 00:00:00 2001 From: voitau Date: Sat, 4 Apr 2020 18:48:26 -0700 Subject: [PATCH 2/2] Generate header in original language --- mdlm.sh | 12 ++++++++++-- test/example-original/README-fr.md.en-it-fr.expected | 6 ++++++ test/example-original/README-it.md.en-it-fr.expected | 6 ++++++ test/example-original/README-it.md.en-it.expected | 6 ++++++ test/test-add.bats | 1 + 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/mdlm.sh b/mdlm.sh index bde9abb..188b876 100755 --- a/mdlm.sh +++ b/mdlm.sh @@ -130,8 +130,16 @@ mdlm_copy_original_to_localized_file() { command echo "${HEADER}" > "${LCM_FILE}" command grep -v "${MDLM_HEADER}" "${ORIG_FILE}" \ | sed -e "/$MDLM_IGNORE_START/,/$MDLM_IGNORE_END/d" \ - | awk -v RS="(^|\n)#" -v popen="${MDLM_P_OPEN}" -v pclose="${MDLM_P_CLOSE}" -v ptbd="${MDLM_P_TBD}" \ - '{ if ($0) print popen "\n#" $0 pclose "\n" ptbd "\n"}' >> "${LCM_FILE}" + | awk -v popen="${MDLM_P_OPEN}" -v pclose="${MDLM_P_CLOSE}" -v ptbd="${MDLM_P_TBD}" \ + 'BEGIN { + RS="(^|\n)#"; + FS="\n"; + } + { + if ($0) { + print popen "\n#" $0 pclose "\n\n#" $1 "\n\n" ptbd "\n" + } + }' >> "${LCM_FILE}" } mdlm_add_locale() { diff --git a/test/example-original/README-fr.md.en-it-fr.expected b/test/example-original/README-fr.md.en-it-fr.expected index 7534b59..3603dbf 100644 --- a/test/example-original/README-fr.md.en-it-fr.expected +++ b/test/example-original/README-fr.md.en-it-fr.expected @@ -4,6 +4,9 @@ Here is a text of example. l10n:p --> + +## Example A + TBD + +### References + TBD diff --git a/test/example-original/README-it.md.en-it-fr.expected b/test/example-original/README-it.md.en-it-fr.expected index 85f265e..99befe2 100644 --- a/test/example-original/README-it.md.en-it-fr.expected +++ b/test/example-original/README-it.md.en-it-fr.expected @@ -5,6 +5,9 @@ Here is a text of example. l10n:p --> + +## Example A + TBD + +### References + TBD diff --git a/test/example-original/README-it.md.en-it.expected b/test/example-original/README-it.md.en-it.expected index e00b9e9..e70a60c 100644 --- a/test/example-original/README-it.md.en-it.expected +++ b/test/example-original/README-it.md.en-it.expected @@ -5,6 +5,9 @@ Here is a text of example. l10n:p --> + +## Example A + TBD + +### References + TBD diff --git a/test/test-add.bats b/test/test-add.bats index 50253b3..0c538da 100644 --- a/test/test-add.bats +++ b/test/test-add.bats @@ -38,6 +38,7 @@ teardown() { run diff "${ORIG_FILE}" "${ORIG_FILE_EXP_IT_FR}" [ $status -eq 0 ] + diff "${LCM_FILE_IT}" "${LCM_FILE_IT_EXP_EN_IT_FR}" run diff "${LCM_FILE_IT}" "${LCM_FILE_IT_EXP_EN_IT_FR}" [ $status -eq 0 ]