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

New: add utility function for dynamic string translation #975

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

alexmigf
Copy link
Member

@alexmigf alexmigf commented Jan 3, 2025

closes #974

This function uses the translate() function to retrieve translations for runtime-determined strings, with a fallback to the original string if no translation exists. It ensures compatibility with existing .po translations while safely handling cases where the translate() function is unavailable.

@alexmigf alexmigf requested a review from MohamadNateqi January 3, 2025 10:24
Copy link
Contributor

@MohamadNateqi MohamadNateqi left a comment

Choose a reason for hiding this comment

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

LGTM!

May I know where this function is going to be used?

@alexmigf
Copy link
Member Author

alexmigf commented Jan 3, 2025

For dynamic strings where traditional functions bypass gettext, such as in cases like:

__( $string, 'textdomain' );

@alexmigf alexmigf merged commit e9bb1aa into main Jan 3, 2025
5 checks passed
@alexmigf alexmigf deleted the 974-dynamic-string-translation-function branch January 3, 2025 11:02
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.

Dynamic string translation function
2 participants