Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function TranslationHeader({ locale }: TranslationHeaderProps) {
<div className="text-h4">
{nameForLocale(locale)} ({locale})
</div>
<div className="status">Needs Reviewing</div>
<div className="status">Needs Sign-off</div>
<div className="flag">{flagForLocale(locale)}</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export function Unchecked({ translation }: { translation: GlossaryEntry }) {
<div className="body">
<p className="text-16 leading-140 mb-10">
How should we translate this word in the context of Exercism? What is
the most natural equivelent in LANGUAGE.
the most natural equivelent in{' '}
{nameForLocale(translation.locale, { displayInEnglish: true })}?
</p>
<div className="flex items-center gap-8 mb-12">
<div className="text-16 w-[105px]">Original (en):</div>
Expand Down
12 changes: 8 additions & 4 deletions app/javascript/utils/name-for-locale.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { capitalize } from 'lodash'

export function nameForLocale(locale: string) {
export function nameForLocale(
locale: string,
options: { displayInEnglish?: boolean } = { displayInEnglish: false }
) {
const [language] = locale.split('-')
const languageName = new Intl.DisplayNames([locale], { type: 'language' }).of(
language
)
const displayLocale = options.displayInEnglish ? 'en' : locale
const languageName = new Intl.DisplayNames([displayLocale], {
type: 'language',
}).of(language)

return capitalize(languageName)
}
Loading