Skip to content

Commit

Permalink
Merge pull request #613 from SamR1/enable-bg-translations
Browse files Browse the repository at this point in the history
Enable Bulgarian translations
  • Loading branch information
SamR1 committed Aug 31, 2024
2 parents d36d3c2 + 9bda697 commit ad71bf1
Show file tree
Hide file tree
Showing 15 changed files with 709 additions and 660 deletions.
2 changes: 1 addition & 1 deletion fittrackee/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
else ''
)
SUPPORTED_LANGUAGES = [
# 'bg', # Bulgarian - disabled for now
'bg', # Bulgarian
'cs', # Czech
'de', # German
'en', # English
Expand Down
4 changes: 2 additions & 2 deletions fittrackee/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<link rel="stylesheet" href="/static/css/fork-awesome.min.css"/>
<link rel="stylesheet" href="/static/css/leaflet.css"/>
<title>FitTrackee</title>
<script type="module" crossorigin src="/static/index-DQ7xav_K.js"></script>
<script type="module" crossorigin src="/static/index-hb5LZD5e.js"></script>
<link rel="modulepreload" crossorigin href="/static/charts-lWJH0bM4.js">
<link rel="modulepreload" crossorigin href="/static/maps-BFpqWvfo.js">
<link rel="stylesheet" crossorigin href="/static/css/maps-HupOsEJb.css">
<link rel="stylesheet" crossorigin href="/static/css/index-_u_9KiAp.css">
<link rel="stylesheet" crossorigin href="/static/css/index-Bg51Oc16.css">
</head>
<body>
<div id="app"></div>
Expand Down

Large diffs are not rendered by default.

640 changes: 0 additions & 640 deletions fittrackee/dist/static/index-DQ7xav_K.js

This file was deleted.

659 changes: 659 additions & 0 deletions fittrackee/dist/static/index-hb5LZD5e.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</template>
<template #content>
<SportRecordsTable
:class="{ 'max-width': maxWidth }"
v-for="record in getTranslatedRecords(records.records)"
:record="record"
:key="record.id"
Expand All @@ -17,11 +18,14 @@
</template>

<script setup lang="ts">
import { toRefs } from 'vue'
import { computed, toRefs } from 'vue'
import type { ComputedRef } from 'vue'
import { useI18n } from 'vue-i18n'
import SportRecordsTable from '@/components/Common/SportRecordsTable.vue'
import { ROOT_STORE } from '@/store/constants'
import type { ICardRecord, IRecord, IRecordsBySport } from '@/types/workouts'
import { useStore } from '@/use/useStore'
import { sortRecords } from '@/utils/records'
interface Props {
Expand All @@ -32,8 +36,14 @@
const { records, sportTranslatedLabel } = toRefs(props)
const store = useStore()
const { t } = useI18n()
const language: ComputedRef<string> = computed(
() => store.getters[ROOT_STORE.GETTERS.LANGUAGE]
)
const maxWidth: ComputedRef<boolean> = computed(() => language.value === 'bg')
function getTranslatedRecords(records: IRecord[]): ICardRecord[] {
const translatedRecords: ICardRecord[] = []
records.map((record) => {
Expand Down Expand Up @@ -99,6 +109,15 @@
}
}
}
@media screen and (max-width: $x-small-limit) {
.card-content {
.record.max-width {
.record-type {
max-width: 40%;
}
}
}
}
}
}
</style>
4 changes: 4 additions & 0 deletions fittrackee_client/src/components/Statistics/StatsMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@
.chart-arrow {
cursor: pointer;
@media screen and (max-width: $x-small-limit) {
padding: 6px;
}
}
}
.stats-type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
() => store.getters[ROOT_STORE.GETTERS.LANGUAGE]
)
const userLanguage = computed(() =>
props.user.language
props.user.language && props.user.language in languageLabels
? languageLabels[props.user.language]
: languageLabels['en']
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
import type { IUserPreferencesPayload, IAuthUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore'
import { availableDateFormatOptions } from '@/utils/dates'
import { availableLanguages } from '@/utils/locales'
import { availableLanguages, languageLabels } from '@/utils/locales'
interface Props {
user: IAuthUserProfile
Expand Down Expand Up @@ -306,7 +306,8 @@
? user.use_raw_gpx_speed
: false
userForm.imperial_units = user.imperial_units ? user.imperial_units : false
userForm.language = user.language ? user.language : 'en'
userForm.language =
user.language && user.language in languageLabels ? user.language : 'en'
userForm.timezone = user.timezone ? user.timezone : 'Europe/Paris'
userForm.date_format = user.date_format ? user.date_format : 'dd/MM/yyyy'
userForm.weekm = user.weekm ? user.weekm : false
Expand Down
4 changes: 2 additions & 2 deletions fittrackee_client/src/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createI18n } from 'vue-i18n'

// import bgMessages from '@/locales/bg/bg'
import bgMessages from '@/locales/bg/bg'
import csMessages from '@/locales/cs/cs'
import deMessages from '@/locales/de/de'
import enMessages from '@/locales/en/en'
Expand All @@ -20,7 +20,7 @@ export default createI18n({
fallbackLocale: 'en',
globalInjection: true,
messages: {
// bg: bgMessages,
bg: bgMessages,
cs: csMessages,
de: deMessages,
en: enMessages,
Expand Down
11 changes: 8 additions & 3 deletions fittrackee_client/src/store/modules/root/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { enUS } from 'date-fns/locale'
import type { MutationTree } from 'vuex'

import { ROOT_STORE } from '@/store/constants'
import type { IRootState, TRootMutations } from '@/store/modules/root/types'
import type { TAppConfig, IAppStatistics } from '@/types/application'
import type { TLanguage } from '@/types/locales'
import { localeFromLanguage } from '@/utils/locales'

export const mutations: MutationTree<IRootState> & TRootMutations = {
[ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES](state: IRootState) {
state.errorMessages = null
Expand Down Expand Up @@ -42,8 +42,13 @@ export const mutations: MutationTree<IRootState> & TRootMutations = {
state.application.statistics = statistics
},
[ROOT_STORE.MUTATIONS.UPDATE_LANG](state: IRootState, language: TLanguage) {
state.language = language
state.locale = localeFromLanguage[language]
if (language in localeFromLanguage) {
state.language = language
state.locale = localeFromLanguage[language]
} else {
state.language = 'en'
state.locale = enUS
}
},
[ROOT_STORE.MUTATIONS.UPDATE_DARK_MODE](
state: IRootState,
Expand Down
2 changes: 1 addition & 1 deletion fittrackee_client/src/types/locales.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type TLanguage =
// | 'bg' // disabled for now
| 'bg'
| 'cs'
| 'de'
| 'en'
Expand Down
2 changes: 1 addition & 1 deletion fittrackee_client/src/utils/dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const availableDateFormats = [
'date_string', // depending on language
]
export const dateStringFormats: Record<TLanguage, string> = {
// bg: 'd MMMM yyyy',
bg: 'd MMMM yyyy',
cs: 'd. MMM yyyy',
de: 'do MMM yyyy',
en: 'MMM. do, yyyy',
Expand Down
10 changes: 5 additions & 5 deletions fittrackee_client/src/utils/locales.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Locale } from 'date-fns'
import {
// bg,
bg,
cs,
de,
enUS,
Expand All @@ -22,7 +22,7 @@ export const isLanguageSupported = (
language: string
): language is TLanguage => {
return [
// 'bg',
'bg',
'cs',
'de',
'en',
Expand All @@ -39,7 +39,7 @@ export const isLanguageSupported = (
}

export const localeFromLanguage: Record<TLanguage, Locale> = {
// bg: bg,
bg: bg,
cs: cs,
de: de,
en: enUS,
Expand All @@ -55,7 +55,7 @@ export const localeFromLanguage: Record<TLanguage, Locale> = {
}

export const languageLabels: Record<TLanguage, string> = {
// bg: 'български',
bg: 'български',
cs: 'Česky (72%)',
de: 'Deutsch (98%)',
en: 'English',
Expand All @@ -64,8 +64,8 @@ export const languageLabels: Record<TLanguage, string> = {
fr: 'Français',
gl: 'Galego (99%)',
it: 'Italiano (82%)',
nb: 'Norsk bokmål (52%)',
nl: 'Nederlands (99%)',
nb: 'Norsk bokmål (52%)',
pl: 'Polski (91%)',
pt: 'Português (98%)',
}
Expand Down
1 change: 1 addition & 0 deletions fittrackee_client/src/utils/password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { zxcvbnOptions } from '@zxcvbn-ts/core'
export const loadLanguagePackage = async (language: string) => {
// no package available for
// - Basque
// - Bulgarian
// - Dutch (nl-NL)
// - Galician
// - Norwegian bokmål
Expand Down

0 comments on commit ad71bf1

Please sign in to comment.