Skip to content

Commit

Permalink
fix(i18n): fix escaping issue in i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
AltGr committed May 9, 2023
1 parent 1b88a18 commit e060517
Show file tree
Hide file tree
Showing 5 changed files with 643 additions and 628 deletions.
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,22 @@ static/dune:
# Generates up-to-date translation template for lang % from the sources
LANGS = $(patsubst translations/%.po,%,$(wildcard translations/*.po))
translations/$(LANGS:=.pot):
@for f in $(LANGS); do echo >> translations/$$f.po; done
@rm -f translations/*.pot
@for f in $(LANGS); do \
echo >> translations/$$f.po; \
rm -f translations/$$f.pot; \
cp translations/$$f.po.header translations/$$f.pot; \
done
@${DUNE} clean ${DUNE_ARGS}
-rm -f ${INDEX_ODOC_PATH}
@DUMP_POT=1 ${DUNE} build ${DUNE_ARGS} -j 1
@for f in $(LANGS); do \
mv translations/$$f.pot translations/$$f.pot.bak; \
msguniq translations/$$f.pot.bak > translations/$$f.pot; \
rm translations/$$f.pot.bak; \
msguniq -t utf-8 translations/$$f.pot.bak > translations/$$f.pot \
&& rm translations/$$f.pot.bak; \
done

.PHONY: translations/$(LANGS:=.pot)

# Updates existing translations (.po) for the latest source template
update-%-translation: translations/%.pot
@msgmerge -U translations/$*.po translations/$*.pot
Expand Down
2 changes: 1 addition & 1 deletion src/app/learnocaml_teacher_tab_doc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let exercises_pane_md =
Those can also be pre-defined in the exercises metadata.
1. Select the exercises to tag
2. Select or type a new tag in one of the boxes on the lower-right of the pane
(left for requirements, right skills trained by the exercise)
(left for requirements, right for skills trained by the exercise)
3. Click the corresponding [+] button to add the tag ([-] to remove)

- **Checking an exercise contents**
Expand Down
2 changes: 1 addition & 1 deletion src/utils/dune
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
(wrapped false)
(flags :standard -warn-error -4-42-44-45-48)
(kind ppx_rewriter)
(libraries ocaml-migrate-parsetree)
(libraries ocaml-migrate-parsetree re)
(modules Ppx_ocplib_i18n)
)

Expand Down
6 changes: 5 additions & 1 deletion src/utils/ppx_ocplib_i18n.ml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ let dump_pot () =
Format.pp_print_char fmt ' ';
Location.print_loc fmt l)
locs;
Format.fprintf fmt "\nmsgid %S\n" s;
Format.fprintf fmt "\nmsgid \"%s\"\n"
Re.(s |>
replace_string (compile (char '\\')) ~by:"\\\\" |>
replace_string (compile (char '"')) ~by:"\\\"" |>
replace_string (compile (char '\n')) ~by:"\\n");
Format.fprintf fmt "msgstr \"\"\n\n";
) misses;
close_out oc
Expand Down
Loading

0 comments on commit e060517

Please sign in to comment.