Skip to content

Fetch translations from API? #783

Answered by Demivan
Nobi322 asked this question in Q&A
Jul 29, 2022 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Hi. It is quite easy to do in userland already.

https://fluent-vue.demivan.me/howto/importing-ftl-files.html combine this with fetching.

Pseudocode:

import { FluentBundle, FluentResource } from '@fluent/bundle'

function changeLocale(locale) {
  // Or any other way of fetching messages
  const messages = await fetch(`/translations/${locale}.ftl`)

  const bundle = new FluentBundle(locale)
  bundle.addResource(new FluentResource(messages))

  fluent.bundles = [bundle]
}

Or you have something else in mind?

P.S.
Thanks for kind words. Героям Слава!

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Nobi322
Comment options

@Demivan
Comment options

@Nobi322
Comment options

@Demivan
Comment options

Answer selected by Demivan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants