Replies: 1 comment 3 replies
-
If you really need to translate using RESX, yes, the best way is with a C# project. I initially wanted to add I18N to FabulousContacts and decided to externalize the strings in a module. So I guess you can go the same way by passing around the user language. module Strings =
let hello lang = match lang with EN -> "Hello" | FR -> "Bonjour"
View.Label(text = Strings.hello model.Language) And trigger an update when user changes the language. If you don't want to pass around the language, a stateful singleton is also an option [<AbstractClass; Sealed>]
type Strings private () =
static let strings = [
"mainpage.hello", "Hello", "Bonjour"
]
static let mutable _lang = EN
static member SetLanguage(lang) = _lang <- lang
static member Get(key) =
let _, en, fr = strings |> List.find(fun (k,_,_) -> k = key)
match _lang with
| EN -> en
| FR -> fr
View.Label(text = Strings.Get("mainpage.hello")) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been doing dome research about this topic and and the main approach used is RESX files as you can read here link.
I have not still tried it . I guess the only alternative will be to create C# Library(Adding all the resx files and reference it from F#
I was wondering if you know different approach that we can use in Fabulous .
Beta Was this translation helpful? Give feedback.
All reactions