Skip to content

Commit

Permalink
Hide knowledge of the special Crowdin locale
Browse files Browse the repository at this point in the history
Refs #2116
  • Loading branch information
thewilkybarkid committed Dec 12, 2024
1 parent cb069c1 commit ab1517b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .dev/locale-index.ts.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ export type SupportedLocale = {{#locales}}| '{{.}}'{{/locales}}

export const DefaultLocale: SupportedLocale = '{{defaultLocale}}'

export const CrowdinInContextLocale: SupportedLocale = '{{crowdinInContextLocale}}'

export const SupportedLocales = HashSet.fromIterable<SupportedLocale>([{{#locales}}'{{.}}', {{/locales}}])

export const UserSelectableLocales = HashSet.fromIterable<SupportedLocale>([{{#locales}}'{{.}}', {{/locales}}]).pipe(HashSet.remove('lol-US'))
export const UserSelectableLocales = HashSet.fromIterable<SupportedLocale>([{{#locales}}'{{.}}', {{/locales}}]).pipe(HashSet.remove('{{crowdinInContextLocale}}'))

export const isSupportedLocale = (locale: string): locale is SupportedLocale =>
[{{#locales}}'{{.}}', {{/locales}}].includes(locale)
Expand Down
1 change: 1 addition & 0 deletions scripts/intlc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -e
. "$(which mo)"

defaultLocale="en-US"
crowdinInContextLocale="lol-US"
modules=$(find "locales/$defaultLocale" -name "*.json" -exec basename "{}" .json \;)
assetsModules=("collapsible-menu" "html-editor" "single-use-form")
mapfile -t srcModules < <(printf "%s\n" "${modules[@]}" "${assetsModules[@]}" "${assetsModules[@]}" | sort | uniq -u)
Expand Down
4 changes: 2 additions & 2 deletions src/WebApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ExpressHttpApp } from './ExpressHttpApp.js'
import { expressServer } from './ExpressServer.js'
import { CanChooseLocale, UseCrowdinInContext } from './feature-flags.js'
import { LegacyRouter } from './LegacyRouter.js'
import { DefaultLocale, SupportedLocales } from './locales/index.js'
import { CrowdinInContextLocale, DefaultLocale, SupportedLocales } from './locales/index.js'
import { PublicUrl } from './public-url.js'
import { FlashMessageSchema } from './response.js'
import { Router } from './Router.js'
Expand Down Expand Up @@ -170,7 +170,7 @@ const getLocale = HttpMiddleware.make(app =>
const useCrowdinInContext = yield* UseCrowdinInContext

if (useCrowdinInContext) {
return yield* Effect.provideService(app, Locale, 'lol-US')
return yield* Effect.provideService(app, Locale, CrowdinInContextLocale)
}

if (!canChooseLocale) {
Expand Down

0 comments on commit ab1517b

Please sign in to comment.