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

A "localize" composable and directive would be useful #2024

Open
3 tasks done
eric-g-97477 opened this issue Nov 20, 2024 · 0 comments
Open
3 tasks done

A "localize" composable and directive would be useful #2024

eric-g-97477 opened this issue Nov 20, 2024 · 0 comments
Labels
Status: Proposal Request for comments

Comments

@eric-g-97477
Copy link

Clear and concise description of the problem

A common pattern I have when using this fantastic package is:

		const key = 'key.path';
		const localized = te(key) ? t(key) : 'Fallback Translation';

This is cumbersome to do over and over again.

Suggested solution

It would be nice if a composable could be provided which did that by allowed me to do:

const localized = localize( 'key.path', 'Fallback Translation' );

localize would look like:

function localize( key, fallback ) {
    return te(key) ? t(key) : fallback;
}

Then, having a related v-localize directive would be useful....

<div v-localize="{ key: 'key.path', fallback: 'Fallback Translation' }" />

Alternative

No response

Additional context

No response

Validations

@eric-g-97477 eric-g-97477 added the Status: Proposal Request for comments label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Proposal Request for comments
Projects
None yet
Development

No branches or pull requests

1 participant