mlverse / torch

R Interface to Torch
https://torch.mlverse.org
Other
483 stars 66 forks source link

Translate/french #1113

Closed cregouby closed 4 months ago

cregouby commented 9 months ago

A frugal proposal for enabling translations of the package, with release of the French translation

FYI, the message extraction relies now on custom translation functions passed to {potools} to form the po/R-torch.pot file:

potools::po_extract(torch_dir, custom_translation_functions = list(R=c(
  "value_error:...\\env", 
  "type_error:...\\env", 
  "runtime_error:...\\env", 
  "not_implemented_error:...\\env",
  "warn:...\\env",
  "stop_iteration_error:...\\env", 
  "deprecated:...\\env") ))
dfalbel commented 8 months ago

Hi @cregouby ! Looks great! Thank you very much! I'm trying to test it locally, but wasn't able to get the translated messages, is there somehting special I should do to enable them?

I basically installed torch from this PR and now trying to run the below, but still getting the error message ein english.

> library(torch)
> withr::with_language("fr", {nn_conv1d(3, 3, 2, 1, padding_mode = "bad_padding")})
Error in `value_error()`:
! padding_mode must be one of [zeros, reflect, replicate, circular],but got padding_mode='bad_padding'.
cregouby commented 8 months ago

Oups, sorry for that. I'm still stuck in the local compilation so I'm not really able to test it locally. I'll check it differently...

dfalbel commented 8 months ago

No worries! Do you want to schedule some time to talk about #1107 ? I can't also reproduce locally, but feels like some old libtorch is being picked up by when compiling lantern.

cregouby commented 8 months ago

Hello, Thanks for the proposal, #1107 is fine now. (just using the procedure in CONTRIBUTION.md). And I do encounter the same bypass of the translation file. I'll dig in it.