-
Notifications
You must be signed in to change notification settings - Fork 21
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
FEATURE REQUEST: Add support for translated error messages using gettext #4
Comments
Hi @diderich, thanks for opening this issue. I want to understand more about this feature. Do you mean you I also want to note that some error messages come from the DeepL API, this package only forwards those messages on. |
My use case is as follows: I am developing an application (i.e., a server that will display photos and associated captions in the language of the end user). I want the application to display all information in the language selected by the user of the application. The application contains two types of text to be localized:
In the case of error messages generated by third-party APIs, I am using the second method to translate them (dynamic translation). But this does not work with error messages from the DeepL API, as by reason for the error, the translation API is unavailable. I currently see two possible approaches for showing localized DeepL API error messages to the user, that is, 1) the engineering approach, and 2) the designer approach: Engineering approachThe DeepL API will
These approaches would allow my (or anyone using the API) application to generate and translate whatever error message I/they want to show. Designer approachThe DeepL will provide support for using the Parameter handlingBoth approaches have one additional challenge: How to handle parameters in the error message, e.g., if the error is that the language selected is unknown, how to return the actually unknown language. For example |
Thank you for the very detailed explanation! I understand what you mean now. Regarding the Engineering approach, there are some unique exceptions in this PHP library for the common error cases, for example PS: As an aside, I assume you are using the "language unknown" error messages as an example, but if not: to avoid errors about unsupported languages, you can list the available languages using |
It would be great if the error messages would be translatable through
gettext
, eg.,_("Error message").'. '._("Language").' '.$lang.' '._("not supported")
.The text was updated successfully, but these errors were encountered: