Skip to content

Commit

Permalink
Merge pull request #8 from cregouby/translation/fr
Browse files Browse the repository at this point in the history
add FR translation
  • Loading branch information
dfalbel authored Sep 17, 2024
2 parents 8f85129 + 593e2fd commit acf8584
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 7 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Title: Hugging Face Hub Interface
Version: 0.1.1.9000
Authors@R: c(
person("Daniel", "Falbel", , "[email protected]", role = c("aut", "cre")),
person("Regouby", "Christophe", , "[email protected]", c("ctb")),
person(family = "Posit", role = c("cph"))
)
Description: Provides functionality to download and cache files from 'Hugging Face Hub' <https://huggingface.co/models>.
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# hfhub (development version)

* Added FR translation of the R messages. (#8 @cregouby)

# hfhub 0.1.1

* Added a `NEWS.md` file to track changes to the package.
Expand Down
14 changes: 7 additions & 7 deletions R/hub_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ hub_download <- function(repo_id, filename, ..., revision = "main", repo_type =

commit_hash <- metadata$commit_hash
if (is.null(commit_hash)) {
cli::cli_abort("Distant resource does not seem to be on huggingface.co (missing commit header).")
cli::cli_abort(gettext("Distant resource does not seem to be on huggingface.co (missing commit header)."))
}

etag <- metadata$etag
if (is.null(etag)) {
cli::cli_abort("Distant resource does not have an ETag, we won't be able to reliably ensure reproducibility.")
cli::cli_abort(gettext("Distant resource does not have an ETag, we won't be able to reliably ensure reproducibility."))
}

# Expected (uncompressed) size
Expand Down Expand Up @@ -90,22 +90,22 @@ hub_download <- function(repo_id, filename, ..., revision = "main", repo_type =
}

if (local_files_only) {
cli::cli_abort(paste0(
cli::cli_abort(gettext(
"Cannot find the requested files in the disk cache and",
" outgoing traffic has been disabled. To enable hf.co look-ups",
" and downloads online, set 'local_files_only' to False."
))
} else {
cli::cli_abort(paste0(
cli::cli_abort(gettext(
"Connection error, and we cannot find the requested files in",
" the disk cache. Please try again or make sure your Internet",
" connection is on."
))
}
}

if (is.null(etag)) cli::cli_abort("etag must have been retrieved from server")
if (is.null(commit_hash)) cli::cli_abort("commit_hash must have been retrieved from server")
if (is.null(etag)) cli::cli_abort(gettext("etag must have been retrieved from server"))
if (is.null(commit_hash)) cli::cli_abort(gettext("commit_hash must have been retrieved from server"))

blob_path <- fs::path(storage_folder, "blobs", etag)
pointer_path <- get_pointer_path(storage_folder, commit_hash, filename)
Expand Down Expand Up @@ -153,7 +153,7 @@ hub_download <- function(repo_id, filename, ..., revision = "main", repo_type =
curl::curl_download(url, tmp, handle = handle, quiet = FALSE)
cli::cli_progress_done(id = bar_id)
}, error = function(err) {
cli::cli_abort("Error downloading from {.url {url}}", parent = err)
cli::cli_abort(gettext("Error downloading from {.url {url}}"), parent = err)
})
fs::file_move(tmp, blob_path)

Expand Down
Binary file added inst/po/fr/LC_MESSAGES/R-hfhub.mo
Binary file not shown.
95 changes: 95 additions & 0 deletions po/R-fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
msgid ""
msgstr ""
"Project-Id-Version: hfhub 0.1.1.9000\n"
"POT-Creation-Date: 2024-09-04 19:28+0200\n"
"PO-Revision-Date: 2024-09-04 19:49+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.4.3\n"

#: hub_download.R:47
msgid ""
"Distant resource does not seem to be on huggingface.co (missing commit "
"header)."
msgstr ""
"La ressource ne semble pas être disponible sur huggingface.co (début de "
"commit manquant)."

#: hub_download.R:52
msgid ""
"Distant resource does not have an ETag, we won't be able to reliably ensure "
"reproducibility."
msgstr ""
"La ressource distante n'a pas d'ETag, il n'y aura donc pas de garantie de "
"reproductibilité."

#: hub_download.R:94
msgid "Cannot find the requested files in the disk cache and"
msgstr ""
"Impossible de trouver les fichiers demandés dans le cache du disque et"

#: hub_download.R:95
msgid "outgoing traffic has been disabled. To enable hf.co look-ups"
msgstr "le trafic sortant a été désactivé. Pour activer les requêtes hf.co"

#: hub_download.R:96
msgid "and downloads online, set 'local_files_only' to False."
msgstr ""
"et les téléchargements en ligne, définissez 'local_files_only = FALSE'."

#: hub_download.R:100
msgid "Connection error, and we cannot find the requested files in"
msgstr ""
"Erreur de connexion, et impossible de trouver les fichiers demandés dans"

#: hub_download.R:101
msgid "the disk cache. Please try again or make sure your Internet"
msgstr ""
"le cache du disque. Veuillez réessayer ou vérifiez que votre connexion "
"Internet"

#: hub_download.R:102
msgid "connection is on."
msgstr "est activée."

#: hub_download.R:107
msgid "etag must have been retrieved from server"
msgstr "l'ETag doit être téléchargé depuis le serveur."

#: hub_download.R:108
msgid "commit_hash must have been retrieved from server"
msgstr "'commit_hash' doit être téléchargé du serveur."

#: hub_download.R:156
msgid "Error downloading from {.url {url}}"
msgstr "Erreur de téléchargement depuis {.url {url}}"

#: hub_download.R:170
msgid "https://huggingface.co/{repo_id}/resolve/{revision}/{filename}"
msgstr "https://huggingface.co/{repo_id}/resolve/{revision}/{filename}"

#: hub_download.R:172
msgid ""
"https://huggingface.co/{repo_type}s/{repo_id}/resolve/{revision}/{filename}"
msgstr ""
"https://huggingface.co/{repo_type}s/{repo_id}/resolve/{revision}/{filename}"

#: hub_download.R:185
msgid "{repo_type}s{REPO_ID_SEPARATOR()}{repo_id}"
msgstr "{repo_type}s{REPO_ID_SEPARATOR()}{repo_id}"

#: hub_info.R:8
msgid "https://huggingface.co/api/models/{repo_id}"
msgstr "https://huggingface.co/api/models/{repo_id}"

#: hub_info.R:10
msgid "https://huggingface.co/api/{repo_type}s/{repo_id}"
msgstr "https://huggingface.co/api/{repo_type}s/{repo_id}"

#: hub_info.R:14
msgid "{path}/revision/{revision}"
msgstr "{path}/revision/{revision}"
84 changes: 84 additions & 0 deletions po/R-hfhub.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
msgid ""
msgstr ""
"Project-Id-Version: hfhub 0.1.1.9000\n"
"POT-Creation-Date: 2024-09-04 19:28+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: hub_download.R:47
msgid ""
"Distant resource does not seem to be on huggingface.co (missing commit "
"header)."
msgstr ""

#: hub_download.R:52
msgid ""
"Distant resource does not have an ETag, we won't be able to reliably ensure "
"reproducibility."
msgstr ""

#: hub_download.R:94
msgid "Cannot find the requested files in the disk cache and"
msgstr ""

#: hub_download.R:95
msgid "outgoing traffic has been disabled. To enable hf.co look-ups"
msgstr ""

#: hub_download.R:96
msgid "and downloads online, set 'local_files_only' to False."
msgstr ""

#: hub_download.R:100
msgid "Connection error, and we cannot find the requested files in"
msgstr ""

#: hub_download.R:101
msgid "the disk cache. Please try again or make sure your Internet"
msgstr ""

#: hub_download.R:102
msgid "connection is on."
msgstr ""

#: hub_download.R:107
msgid "etag must have been retrieved from server"
msgstr ""

#: hub_download.R:108
msgid "commit_hash must have been retrieved from server"
msgstr ""

#: hub_download.R:156
msgid "Error downloading from {.url {url}}"
msgstr ""

#: hub_download.R:170
msgid "https://huggingface.co/{repo_id}/resolve/{revision}/{filename}"
msgstr ""

#: hub_download.R:172
msgid ""
"https://huggingface.co/{repo_type}s/{repo_id}/resolve/{revision}/{filename}"
msgstr ""

#: hub_download.R:185
msgid "{repo_type}s{REPO_ID_SEPARATOR()}{repo_id}"
msgstr ""

#: hub_info.R:8
msgid "https://huggingface.co/api/models/{repo_id}"
msgstr ""

#: hub_info.R:10
msgid "https://huggingface.co/api/{repo_type}s/{repo_id}"
msgstr ""

#: hub_info.R:14
msgid "{path}/revision/{revision}"
msgstr ""
20 changes: 20 additions & 0 deletions tests/testthat/test-message-translations.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
test_that("R-level cli_abort messages are correctly translated in FR", {
skip_if_no_token()
withr::with_envvar(c(HUGGINGFACE_HUB_CACHE = tempdir()), {
try({
withr::with_language(
lang = "fr",
expect_error(
hub_download(
repo_id = "dfalbel/test-hfh",
filename = ".gitattributes",
force_download = TRUE
),
regexp = "La ressource ne semble pas être disponible sur",
)

)
})
})

})

0 comments on commit acf8584

Please sign in to comment.