Skip to content

Commit

Permalink
Polish translation (#686)
Browse files Browse the repository at this point in the history
Co-authored-by: Garrick Aden-Buie <garrick@adenbuie.com>
  • Loading branch information
jakub-jedrusiak and gadenbuie authored May 2, 2022
1 parent acce7f6 commit 8cf9f52
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 11 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- German language support was contributed by @NinaCorrelAid (#611, #612)
- Korean language support was contributed by @choonghyunryu (#634)
- Chinese language support was contributed by @shalom-lab (#681)
- Polish language support was contributed by Jakub Jędrusiak (@kuba58426) (#686)

- Messages generated by R during exercises are now translated to match the tutorial language, if translations are available either in base R or in the R package generating the message (@rossellhayes #558).

Expand Down
2 changes: 1 addition & 1 deletion R/praise.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' quiz experience.
#'
#' @param language The language for the random phrase. The currently supported
#' languages include: `en`, `es`, `pt`, `tr`, `de`, `emo`, and `testing`
#' languages include: `en`, `es`, `pt`, `pl`, `tr`, `de`, `emo`, and `testing`
#' (static phrases).
#'
#' @return Character string with a random saying
Expand Down
23 changes: 23 additions & 0 deletions data-raw/i18n_random-phrases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,20 @@ praise:
- 성공하셨습니다!
- 최고의 답변입니다!
- 멋집니다!
pl:
- Świetnie!
- Doskonale!
- Dobra robota!
- Dajesz radę!
- Dobrze Ci idzie!
- Tak trzymaj!
- Oby tak dalej!
- Cudownie!
- Pierwsza klasa!
- Bardzo dobrze!
- Jeśli to zadanie jest skocznią, to Ty jesteś Małyszem!
- Gratulacje!

encouragement:
testing:
- RANDOM ENCOURAGEMENT.
Expand Down Expand Up @@ -231,3 +245,12 @@ encouragement:
- 不要放弃,加油。
- 靡不有初,鲜克有终。
- 没事儿,再来。
pl:
- Nie udało się, ale spróbuj jeszcze raz.
- Na błędach najlepiej się uczymy.
- Nic straconego!
- To co? Może jeszcze jedna próba?
- Nie poddawaj się!
- Wytrwałość to klucz do sukcesu, spróbujmy jeszcze raz.
- Do skutku! Tak możemy się uczyć.
- Nikodemowi Dyzmie też na początku nie było łatwo!
14 changes: 7 additions & 7 deletions data-raw/i18n_translations.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ library(yaml)
library(purrr)
library(stringi)

# We currently use stri_enc_toutf8() instead of the function below.
# We noticed problems with the Polish translation and switch to the function
# from {stringi}. I've kept this function in the source in case we need to
# switch back to our previous method.
reencode_utf8 <- function(x) {

# Ensure that we encode non-UTF-8 strings to UTF-8 in a
# two-step process: (1) to native encoding, and then
# (2) to UTF-8
# two-step process: (1) to native encoding, and then (2) to UTF-8
if (Encoding(x) != 'UTF-8') {
x <- enc2utf8(x)
}
Expand Down Expand Up @@ -79,9 +82,7 @@ translations_list <-
# Drop null keys
map_depth(2, compact) %>%
# Re-encode to UTF-8
map_depth(3, reencode_utf8) %>%
# Unescape unicode
map_depth(3, stri_unescape_unicode) %>%
map_depth(3, stri_enc_toutf8, validate = TRUE) %>%
# Massage into i18next format
# button$runcode$en -> en$translation$button$runcode
map_depth(1, transpose) %>%
Expand All @@ -95,7 +96,6 @@ saveRDS(translations_list, file = here("inst", "internals", "i18n_translations.r
i18n_random_phrases <-
here("data-raw", "i18n_random-phrases.yml") %>%
yaml::read_yaml() %>%
map_depth(3, reencode_utf8) %>%
map_depth(2, map_chr, stri_unescape_unicode)
map_depth(2, map_chr, stri_enc_toutf8, validate = TRUE)

saveRDS(i18n_random_phrases, file = here("inst", "internals", "i18n_random_phrases.rds"), version = 2)
Loading

0 comments on commit 8cf9f52

Please sign in to comment.