Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize on 'en', not 'en-US' as a language code, but register both #868

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion src/hooks.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const handleError = Sentry.handleErrorWithSentry();
/** @type {import('@sveltejs/kit').Handle} */
async function language({ event, resolve }) {
const lang =
event.request.headers.get("accept-language")?.split(",")[0] ?? "en-US";
event.request.headers.get("accept-language")?.split(",")[0] ?? "en";

if (lang) {
locale.set(lang);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/documents/Access.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<script lang="ts">
import { _ } from "svelte-i18n";

import type { Access } from "@/lib/api/types";
import type { Access } from "$lib/api/types";
import type { Level } from "$lib/components/inputs/AccessLevel.svelte";

export let level: Level;
Expand Down
14 changes: 7 additions & 7 deletions src/lib/components/documents/BulkActions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ Most actual actions are deferred to their own forms, so this is more of a switch
const selected: Readable<Document[]> = getContext("selected");

const actions: Record<Action, ActionDetail> = {
share: [$_("bulk.actions.share"), Share16],
edit: [$_("bulk.actions.edit"), Pencil16],
data: [$_("bulk.actions.data"), Tag16],
project: [$_("bulk.actions.project"), FileDirectory16],
reprocess: [$_("bulk.actions.reprocess"), IssueReopened16],
delete: [$_("bulk.actions.delete"), Alert16],
share: ["bulk.actions.share", Share16],
edit: ["bulk.actions.edit", Pencil16],
data: ["bulk.actions.data", Tag16],
project: ["bulk.actions.project", FileDirectory16],
reprocess: ["bulk.actions.reprocess", IssueReopened16],
delete: ["bulk.actions.delete", Alert16],
eyeseast marked this conversation as resolved.
Show resolved Hide resolved
};

let visible: Nullable<Action> = null;
Expand Down Expand Up @@ -76,7 +76,7 @@ Most actual actions are deferred to their own forms, so this is more of a switch
}}
>
<svelte:component this={icon} slot="start" />
{label}
{$_(label)}
</SidebarItem>
{/each}

Expand Down
4 changes: 4 additions & 0 deletions src/lib/i18n/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ LANGUAGES.forEach(([name, code, flag]) => {
}
});

// handle two-part locales
register("en-US", () => import("@/langs/json/en.json"));
register("en-GB", () => import("@/langs/json/en.json"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to handle other two part locales? Spanish is spoken in a lot of countries.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure these are strictly necessary. I think part of the issue was that we were defaulting (in hooks.server.ts) to en-US and that wasn't registered.


init({
fallbackLocale: defaultLocale,
initialLocale: browser ? window.navigator.language : defaultLocale,
Expand Down