-
Notifications
You must be signed in to change notification settings - Fork 999
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
Fixes #4478 - Added API localization #1428
Conversation
The builds are failing on yet unsatisfied dependancy on apipie-rails 0.2.0 |
@@ -8,6 +8,16 @@ | |||
config.ignored_by_recorder = %w[] | |||
config.doc_base_url = "/apidoc" | |||
config.use_cache = Rails.env.production? || File.directory?(config.cache_dir) | |||
config.languages = ['en', 'de'] # [] to turn off localized API docs and CLI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to set the languages properly. Both FastGettext.available_locales and FastGettext.default_available_locales seems to be nil at this point. Any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably the initialiser order, as we set up locales in fast_gettext.rb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to influence the order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename the files as I think they're processed alphabetically.
And where do the api texts gets translated eventually? |
@lzap, that is the bussiness of apipie rake task/controller. The strings are translated during the output to avoid expensive parsing of the sources for each language. |
[test] |
Apipie-rails 0.2.0 was released |
Don't generate for all of them, let's just have a list of "approved" Later, Lukas "lzap" Zapletal |
[test] |
I've turned off generating docs for locales with some hints in the initializer, and let it up to admin what he sets. Would it make sense to move this to settings and let it set and perhaps trigger the rake apipie:cache from the UI? I've fixed some tests, but there are still some left, I would use some help with:
|
Wow, you're right, that does take a long time (1 min 35 seconds on fast i7/SSD laptop for rake apipie:cache). I dislike hard coding a list of languages that are approved, but can see the attractiveness of allowing the admin to choose, a bit like installing "language packs" (maybe we should even package it this way one day). Could we perhaps look at how apipie is actually generating these - is it re-running a large parsing operation for each language rather than parsing once and generating for each language etc? By the way, I hit an error when mark_translated: true in settings.yaml, as apipie tries to translate I might also do a quick proof-read of the docs text before merging so it's in good shape for translators. (As discussed on IRC, we'll sort the RPM failure when coming to merge as apipie-rails 0.2.0's incompatible with develop. Ruby 2.0.0 errors are now fixed.) |
Yes it is slow, on my laptop it takes approx 80 sec. The first minute is initialization of the rails app and parsing the API controllers. Then it takes about 20 sec per language to generate the JSON and HTML data. I'll look at the failing nils. Thanks for fixing the issues... 🍺 |
@domcleal I fixed the failures on nil values |
@domcleal patch was rebased |
@@ -0,0 +1,28 @@ | |||
# Apipie-rails is library we use for ducumenting our API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*documenting
I've proof-read the lot and tried to fix lots of consistency issues - could you squash this in please, if you agree with it? domcleal@6f4843c The remaining things to sort are:
|
Thanks for fixed strings, I'll squash them in |
Updated this PR. The changes arein separate commits that I will squash in before merge. All suported languages were enabled in the initializer. Cache now could be pre-generated during build time. With Apipie/apipie-rails#262 we can generate cache for resources separately during build. On installed instance we can regenerate just the index pages with regard on installed plugins. On foreman with katello it takes about 3sec per language plus task initialization which seems acceptable. The downside is that all the plugins needs to be built with pre-generated cache or the plugin cache generation has to be run manually with
For the rake task to know the plugin's API controllers I extended foreman plugin with two attrs. If this will be found viable I can fix the spec files and installer. The only not addressed thing still remains apipie internal strings, which will follow |
The PR reflecting plugin changes in katello is here Katello/katello#4375 |
rebased |
Hmmm, lgtm. Can you raise a PR to the foreman-packaging repo for the Later, Lukas "lzap" Zapletal |
@mbacovsky rebase needed |
@mbacovsky it may help to split this PR into two - one that simply adds API strings for extraction so we can get them into Transifex and avoid more rebasing & conflicts with other PRs, and then keep this open for the apipie and plugins work. I'd be happy to merge the extractions ASAP as I think it'll make our lives easier and it has no other impact. |
d16dcc2
to
a39f1e1
Compare
@lzap, @domcleal, updated, rebased. PR description updated, known issues added there. API cache is now build for all supported languages. Part is build during build time and part after installation. Rough times for comparsion are in the PR description. Katello PR was updated. foreman-packaging PR was added theforeman/foreman-packaging#426 |
Rubocop failure. |
a39f1e1
to
9920782
Compare
Rubocop issues fixed |
Merged as a59972c thanks @mbacovsky! |
This PR contains
Doc build duration for reference: Foreman in sec (Foreman + Katello in min:sec) for all supported languages
Resources can be built during package build time and index after package installation.
Known issues:
Related PR in apipie-rails Apipie/apipie-rails#232
Related PR with API doc string marked for translation #1626