Skip to content

Fix Translation not found when contains non-standard character #401

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

Conversation

N1ebieski
Copy link
Contributor

@N1ebieski N1ebieski commented Jun 9, 2025

Fixes #400

This PR depends on laravel/vs-code-php-parser-cli#21

Currently, the translations.php template uses json_encode without any flags. As a result, during serialization to JSON, all symbols and slashes are escaped. For example:

Products → Settings => Products \u2192 Settings

API / ERP => API \/ ERP

then linkProvider cannot find such elements in the translation repository, because VsCode returns raw, unescaped keys.

This PR adds 2 additional flags to json_encode: JSON_UNESCAPED_UNICODE and JSON_UNESCAPED_SLASHES. I'm not 100% sure but I think, both javascript object and php array can use symbols and slashes in the property/key names, so there should be no conflict.

Copy link
Collaborator

@joetannenbaum joetannenbaum left a comment

Choose a reason for hiding this comment

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

Good call, thank you!

@joetannenbaum joetannenbaum merged commit 59678dc into laravel:main Jun 9, 2025
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.

[Bug]: Translation not found when contains non-standard character
2 participants