forked from Mirrors/elk
feat: init inclusive as preference
This commit is contained in:
parent
9a8e645e16
commit
863eab1598
5 changed files with 41 additions and 7 deletions
|
@ -13,6 +13,7 @@ export interface WellnessSettings {
|
|||
hideBoostCount: boolean
|
||||
hideFavoriteCount: boolean
|
||||
hideFollowerCount: boolean
|
||||
useInclusiveWriting: boolean
|
||||
}
|
||||
|
||||
export interface UserSettings {
|
||||
|
@ -38,6 +39,7 @@ export const DEFAULT_WELLNESS_SETTINGS: WellnessSettings = {
|
|||
hideBoostCount: false,
|
||||
hideFavoriteCount: false,
|
||||
hideFollowerCount: false,
|
||||
useInclusiveWriting: true,
|
||||
}
|
||||
|
||||
export const DEFAULT_FEATURE_FLAGS: FeatureFlags = {
|
||||
|
|
|
@ -2,14 +2,21 @@ import type { NuxtI18nOptions } from '@nuxtjs/i18n'
|
|||
import type { DateTimeFormats, NumberFormats, PluralizationRule, PluralizationRules } from '@intlify/core-base'
|
||||
|
||||
import type { LocaleObject } from '#i18n'
|
||||
import { satisfies } from '~~/mocks/semver'
|
||||
|
||||
interface LocaleObjectData extends LocaleObject {
|
||||
numberFormats?: NumberFormats
|
||||
dateTimeFormats?: DateTimeFormats
|
||||
pluralRule?: PluralizationRule
|
||||
interface InclusiveLocaleKey {
|
||||
adoptInclusiveWriting?: boolean
|
||||
inclusiveTransform?: (term: string) => string
|
||||
}
|
||||
declare module '#i18n' {
|
||||
interface LocaleObject extends InclusiveLocaleKey {
|
||||
numberFormats?: NumberFormats
|
||||
dateTimeFormats?: DateTimeFormats
|
||||
pluralRule?: PluralizationRule
|
||||
}
|
||||
}
|
||||
|
||||
const locales: LocaleObjectData[] = [
|
||||
const locales: LocaleObject[] = [
|
||||
{
|
||||
code: 'en-US',
|
||||
file: 'en-US.json',
|
||||
|
@ -29,7 +36,7 @@ const locales: LocaleObjectData[] = [
|
|||
const name = new Intl.PluralRules('ar-EG').select(choice)
|
||||
return { zero: 0, one: 1, two: 2, few: 3, many: 4, other: 5 }[name]
|
||||
},
|
||||
} satisfies LocaleObjectData),
|
||||
} satisfies LocaleObject),
|
||||
{
|
||||
code: 'de-DE',
|
||||
file: 'de-DE.json',
|
||||
|
@ -64,6 +71,10 @@ const locales: LocaleObjectData[] = [
|
|||
code: 'fr-FR',
|
||||
file: 'fr-FR.json',
|
||||
name: 'Français',
|
||||
adoptInclusiveWriting: true,
|
||||
inclusiveTransform(term: string) {
|
||||
return term.replace(/·\w+·?/, '')
|
||||
},
|
||||
},
|
||||
{
|
||||
code: 'uk-UA',
|
||||
|
@ -87,6 +98,16 @@ const locales: LocaleObjectData[] = [
|
|||
file: 'tr-TR.json',
|
||||
name: 'Türkçe',
|
||||
},
|
||||
({
|
||||
code: 'ar-EG',
|
||||
file: 'ar-EG.json',
|
||||
name: 'العربية',
|
||||
dir: 'rtl',
|
||||
pluralRule: (choice: number) => {
|
||||
const name = new Intl.PluralRules('ar-EG').select(choice)
|
||||
return { zero: 0, one: 1, two: 2, few: 3, many: 4, other: 5 }[name]
|
||||
},
|
||||
} satisfies LocaleObject),
|
||||
].sort((a, b) => a.code.localeCompare(b.code))
|
||||
|
||||
const datetimeFormats = Object.values(locales).reduce((acc, data) => {
|
||||
|
|
|
@ -273,6 +273,7 @@
|
|||
},
|
||||
"language": {
|
||||
"display_language": "Display Language",
|
||||
"inclusive": "Use epicene terms (median point)",
|
||||
"label": "Language"
|
||||
},
|
||||
"notifications": {
|
||||
|
|
|
@ -268,6 +268,7 @@
|
|||
},
|
||||
"language": {
|
||||
"display_language": "Langue d'affichage",
|
||||
"inclusive": "Utiliser l'écriture épicène (point médiant)",
|
||||
"label": "Langue"
|
||||
},
|
||||
"notifications": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
const { t } = useI18n()
|
||||
const { t, localeProperties } = useI18n()
|
||||
|
||||
useHeadFixed({
|
||||
title: () => `${t('settings.language.label')} | ${t('nav.settings')}`,
|
||||
|
@ -18,6 +18,15 @@ useHeadFixed({
|
|||
<p font-medium>{{ $t('settings.language.display_language') }}</p>
|
||||
<SettingsLanguage select-settings />
|
||||
</label>
|
||||
|
||||
<SettingsToggleItem
|
||||
v-if="localeProperties.adoptInclusiveWriting"
|
||||
:checked="getWellnessSetting('useInclusiveWriting')"
|
||||
m-t
|
||||
@click="toggleWellnessSetting('useInclusiveWriting')"
|
||||
>
|
||||
{{ $t('settings.language.inclusive') }}
|
||||
</SettingsToggleItem>
|
||||
</div>
|
||||
</MainContent>
|
||||
</template>
|
||||
|
|
Loading…
Reference in a new issue