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

chore: Add localization file #27

Closed
wants to merge 1 commit into from
Closed

chore: Add localization file #27

wants to merge 1 commit into from

Conversation

aklinker1
Copy link
Owner

Example localization for wxt-dev/wxt#343

Comment on lines +10 to +11
getAdditionsText: (count) =>
i18n.tp("diffs_additionsText", count, [String(count)]),
Copy link
Owner Author

@aklinker1 aklinker1 Jan 14, 2024

Choose a reason for hiding this comment

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

Annoying that I have to wrap the number in a string here for the substitution array.

@@ -14,7 +16,7 @@ const emits = defineEmits<{

<textarea
class="font-mono p-2 w-full resize-y m-0 outline-none -mb-1 min-h-[5rem]"
:placeholder="'Enter glob patterns:\n*.lock\n**/vendor/**'"
:placeholder="t('options_customLists_customRepoPlaceholder')"
Copy link
Owner Author

@aklinker1 aklinker1 Jan 14, 2024

Choose a reason for hiding this comment

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

Using underscores make it hard to select individual parts of the key. Double clicking the string selects everything.

But I want to avoid anything at runtime like .replaceAll('.', '_') that could slow things down. So I don't think this is easily solved.

Comment on lines +44 to +47
customRepoPlaceholder: |
Enter glob patterns:
*.lock
**/vendor/**
Copy link
Owner Author

Choose a reason for hiding this comment

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

This works! Easily add newlines to strings.

@@ -20,6 +20,7 @@ export default defineConfig({
manifest: ({ browser }) => {
const manifest: UserManifest = {
permissions: ["storage"],
default_locale: "en",
Copy link
Owner Author

Choose a reason for hiding this comment

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

Remember to add this, otherwise types for i18n.t/i18n.tp won't be generated.

getDeletionsText: (count) => `${count} deletions`,
getGeneratedText: (count) => `${count} generated lines.`,
getAdditionsText: (count) =>
i18n.tp("diffs_additionsText", count, [String(count)]),
Copy link
Owner Author

Choose a reason for hiding this comment

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

I don't like that there's a separate function for plurals. I'd rather just use an override for t with 3 arguments.

@aklinker1
Copy link
Owner Author

Close in favor of #37

@aklinker1 aklinker1 closed this Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant