Skip to content

How to swap out specific terms within a locale for different types of users #716

Answered by ivanhofer
JakeBriscoe asked this question in Q&A
Discussion options

You must be logged in to vote

From what I understand formatters are the thing you are looking for. But indeed, you don't have access to translations in there.
You could create a utility function to get to the translated value instead of using a formatter.

// util
const toTerm = (term: Terms) => $LL.terms[term]()

// translation
title: 'Manage your {0:LocalizedString} here',
terms: {
   fruit: 'fruit store',
   bakery: 'bakery',
}

// +page.svelte
<h2>{$LL.home.title(toTerm(user.type))}</h2>

Hope this is clear

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JakeBriscoe
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