Skip to content

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

Open
@eric-g-97477

Description

@eric-g-97477

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions