OpenAPITools / OpenAPITools/openapi-generator
[REQ] POEdit files generator
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
Imagine multilingual API. There are hardcoded messages which should be translated. The first thing comes to mind is error messages.
components:
schemas:
ClientError:
error_code:
type: integer
example: 400
error_message:
type: string
example: 'Bad request.'
Describe the solution you'd like
en_US.po file:
# it's not enough for all errors, but for 400 bad request as a start
msgid "ClientError.error_message"
msgstr "Bad request."
# obviously error_message field is dynamic then you might need more messages
# uncomment more strings and specify IDs for them
# msgid "ClientError.error_message.2"
# msgstr ""
# msgid "ClientError.error_message.3"
# msgstr ""
ru_RU.po will be identical but user fills in russian translations.
Describe alternatives you've considered
And even more crazy idea. It's really boring to document hundreds of errors in every project. What about multilingual API Error Codes Book file? I think that 99% of APIs use static codes for errors and most of time they are hardcoded. We can generate .po file with error codes mapped to HTTP Status Codes from official standard. We can add template for custom errors like msgid "error_555" etc. If developer uses error code 555 he uncomments this line and adds appropriate message translation.
After that PHP user can use translations with gettext extension like:
$language = "ru_RU";
putenv("LANG=".$language);
setlocale(LC_ALL, $language);
$domain = "error_messages";
bindtextdomain($domain, "locale");
textdomain($domain);
echo gettext("error_400");
/* prints Неверный запрос. */
cc special invite to @jimschubert
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or entry points are named. Start by reviewing the generator's existing architecture and how OpenAPI error responses and schemas are represented; compare that with the proposed en_US.po and ru_RU.po examples. Done would mean a defined way to generate PO files for documented and custom error messages, with the intended gettext usage supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, php
- Domain
- api, localization, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100