haveapi 0.32.1 → 0.32.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -8
  3. data/README.md +3 -422
  4. data/Rakefile +17 -7
  5. data/benchmarks/performance_compare.rb +27 -6
  6. data/doc/cs/client-examples.md +535 -0
  7. data/doc/cs/create-client.md +118 -0
  8. data/doc/cs/json-schema.html +1182 -0
  9. data/doc/cs/protocol.md +595 -0
  10. data/doc/cs/readme.md +432 -0
  11. data/doc/cs/typed-input-validation.md +122 -0
  12. data/doc/{client-examples.md → en/client-examples.md} +20 -10
  13. data/doc/{documentation-ui.md → en/documentation-ui.md} +42 -6
  14. data/doc/{performance.md → en/performance.md} +11 -0
  15. data/doc/{protocol.md → en/protocol.md} +2 -2
  16. data/doc/en/readme.md +423 -0
  17. data/haveapi.gemspec +2 -2
  18. data/lib/haveapi/client_example.rb +18 -5
  19. data/lib/haveapi/client_examples/curl.rb +5 -5
  20. data/lib/haveapi/client_examples/dynamic_helpers.rb +10 -10
  21. data/lib/haveapi/client_examples/go_client.rb +1 -1
  22. data/lib/haveapi/client_examples/http.rb +4 -4
  23. data/lib/haveapi/client_examples/js_client.rb +10 -10
  24. data/lib/haveapi/client_examples/php_client.rb +24 -25
  25. data/lib/haveapi/client_examples/python_client.rb +11 -11
  26. data/lib/haveapi/client_examples/ruby_cli.rb +6 -9
  27. data/lib/haveapi/client_examples/ruby_client.rb +24 -16
  28. data/lib/haveapi/client_examples/rust_client.rb +1 -1
  29. data/lib/haveapi/client_examples/ts_generated_client.rb +1 -1
  30. data/lib/haveapi/documentation_context.rb +14 -2
  31. data/lib/haveapi/documentation_helpers.rb +92 -15
  32. data/lib/haveapi/documentation_locale.rb +65 -0
  33. data/lib/haveapi/documentation_oauth.rb +12 -12
  34. data/lib/haveapi/documentation_search.rb +5 -5
  35. data/lib/haveapi/documentation_validators.rb +43 -33
  36. data/lib/haveapi/locales/cs.yml +468 -0
  37. data/lib/haveapi/locales/en.yml +467 -0
  38. data/lib/haveapi/public/css/documentation.css +8 -4
  39. data/lib/haveapi/public/js/documentation.js +73 -20
  40. data/lib/haveapi/server.rb +32 -47
  41. data/lib/haveapi/shared_documentation_helpers.rb +53 -5
  42. data/lib/haveapi/version.rb +1 -1
  43. data/lib/haveapi/views/doc_layout.erb +3 -2
  44. data/lib/haveapi/views/doc_sidebars/create-client.erb +10 -10
  45. data/lib/haveapi/views/doc_sidebars/json-schema.erb +2 -2
  46. data/lib/haveapi/views/doc_sidebars/protocol.erb +24 -24
  47. data/lib/haveapi/views/documentation/search_form.erb +5 -4
  48. data/lib/haveapi/views/documentation/search_results.erb +6 -6
  49. data/lib/haveapi/views/index.erb +3 -3
  50. data/lib/haveapi/views/main_layout.erb +4 -4
  51. data/lib/haveapi/views/shared_documentation.erb +8 -5
  52. data/lib/haveapi/views/shared_sidebar.erb +11 -11
  53. data/lib/haveapi/views/version_page/auth_body.erb +7 -7
  54. data/lib/haveapi/views/version_page/client_auth.erb +1 -1
  55. data/lib/haveapi/views/version_page/client_example.erb +1 -1
  56. data/lib/haveapi/views/version_page/client_init.erb +1 -1
  57. data/lib/haveapi/views/version_page/client_overview.erb +7 -5
  58. data/lib/haveapi/views/version_page/example_panels.erb +5 -2
  59. data/lib/haveapi/views/version_page/resource_body.erb +24 -24
  60. data/lib/haveapi/views/version_page/resource_directory.erb +2 -2
  61. data/lib/haveapi/views/version_page/usage.erb +5 -5
  62. data/lib/haveapi/views/version_page.erb +11 -11
  63. data/lib/haveapi/views/version_sidebar/auth_nav.erb +2 -2
  64. data/lib/haveapi/views/version_sidebar/authentication_control.erb +8 -8
  65. data/lib/haveapi/views/version_sidebar/authentication_status.erb +1 -1
  66. data/lib/haveapi/views/version_sidebar/brand.erb +16 -5
  67. data/lib/haveapi/views/version_sidebar.erb +33 -18
  68. data/spec/client_examples/assets/documentation_test.cjs +107 -9
  69. data/spec/client_examples/comment_capture.rb +72 -0
  70. data/spec/client_examples/comments_spec.rb +162 -0
  71. data/spec/client_examples/context_spec.rb +18 -2
  72. data/spec/client_examples/detail_spec.rb +68 -0
  73. data/spec/documentation/client_overview_spec.rb +60 -0
  74. data/spec/documentation/example_selection_spec.rb +192 -0
  75. data/spec/documentation/language_settings_spec.rb +132 -0
  76. data/spec/documentation/locale_spec.rb +367 -0
  77. data/spec/documentation/navigation_spec.rb +61 -3
  78. data/spec/documentation/oauth_spec.rb +42 -0
  79. data/spec/documentation/search_index_routes_spec.rb +8 -4
  80. data/spec/documentation/search_spec.rb +1 -1
  81. data/spec/documentation/shared_pages_spec.rb +63 -2
  82. data/spec/documentation/validators_spec.rb +25 -0
  83. data/spec/extensions/exception_mailer_spec.rb +2 -2
  84. data/spec/packaging_spec.rb +68 -9
  85. data/spec/performance/event_baseline_spec.rb +1 -1
  86. data/spec/performance/source_versions_spec.rb +111 -2
  87. metadata +24 -11
  88. /data/doc/{create-client.md → en/create-client.md} +0 -0
  89. /data/doc/{documentation-oauth.md → en/documentation-oauth.md} +0 -0
  90. /data/doc/{json-schema.html → en/json-schema.html} +0 -0
  91. /data/doc/{typed-input-validation.md → en/typed-input-validation.md} +0 -0
@@ -1,12 +1,12 @@
1
1
  <!DOCTYPE html>
2
- <html>
2
+ <html lang="<%= escape_html(documentation_locale) %>">
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <title><%= escape_html(documentation_document_title) %></title>
7
7
  <% if @documentation_ui %>
8
- <script src="<%= escape_html(url('/js/documentation.js', false)) %>" data-highlighter-url="<%= escape_html(url('/js/highlighter.js', false)) %>"></script>
9
- <link rel="stylesheet" href="<%= escape_html(url('/css/documentation.css', false)) %>">
8
+ <script src="<%= escape_html("#{url('/js/documentation.js', false)}?v=#{HaveAPI::DocumentationHelpers::ASSET_DIGESTS.fetch('js/documentation.js')}") %>" data-highlighter-url="<%= escape_html(url('/js/highlighter.js', false)) %>"></script>
9
+ <link rel="stylesheet" href="<%= escape_html("#{url('/css/documentation.css', false)}?v=#{HaveAPI::DocumentationHelpers::ASSET_DIGESTS.fetch('css/documentation.css')}") %>">
10
10
  <% else %>
11
11
 
12
12
  <link rel="stylesheet" href="/css/bootstrap.min.css">
@@ -86,7 +86,7 @@
86
86
 
87
87
  <footer class="docs-footer">
88
88
  <div>
89
- <p class="text-right">Generated by <a href="https://github.com/vpsfreecz/haveapi">HaveAPI</a> v<%= version %></p>
89
+ <p class="text-right"><%= escape_html(documentation_t('footer.generated')) %> <a href="https://github.com/vpsfreecz/haveapi">HaveAPI</a> v<%= version %></p>
90
90
  </div>
91
91
  </footer>
92
92
  </div>
@@ -1,12 +1,15 @@
1
1
  <% if @documentation_page == 'guide' %>
2
- <nav aria-label="Breadcrumb">
2
+ <nav class="docs-breadcrumb" aria-label="<%= escape_html(documentation_t('accessibility.breadcrumb')) %>">
3
3
  <ol>
4
- <li><a href="<%= escape_html(shared_documentation_url) %>">API versions</a></li>
5
- <% unless title == 'HaveAPI internals' %>
6
- <li><a href="<%= escape_html(shared_documentation_url('doc')) %>">HaveAPI internals</a></li>
4
+ <li><a href="<%= escape_html(shared_documentation_url) %>"><%= escape_html(documentation_t('labels.api_versions')) %></a></li>
5
+ <% unless @documentation_article_id == 'readme' %>
6
+ <li><a href="<%= escape_html(shared_documentation_url('doc')) %>"><%= escape_html(documentation_t('articles.readme')) %></a></li>
7
7
  <% end %>
8
8
  <li aria-current="page"><%= escape_html(title) %></li>
9
9
  </ol>
10
10
  </nav>
11
11
  <% end %>
12
- <%= content %>
12
+ <% if @documentation_article_locale && @documentation_article_locale != documentation_locale %>
13
+ <p class="docs-article-fallback"><%= escape_html(documentation_t('article.fallback')) %></p>
14
+ <% end %>
15
+ <div lang="<%= escape_html(@documentation_article_locale || documentation_locale) %>"><%= content %></div>
@@ -2,24 +2,24 @@
2
2
  <% if (search_options = documentation_search_form_options(id: 'docs-search-sidebar')) %>
3
3
  <%= erb :'documentation/search_form', locals: search_options %>
4
4
  <% end %>
5
- <nav aria-label="Documentation pages">
5
+ <nav aria-label="<%= escape_html(documentation_t('accessibility.pages')) %>">
6
6
  <ul>
7
- <li><a href="<%= escape_html(shared_documentation_url) %>"<% if @documentation_page == 'versions' %> aria-current="page"<% end %>>API versions</a></li>
7
+ <li><a href="<%= escape_html(shared_documentation_url) %>"<% if @documentation_page == 'versions' %> aria-current="page"<% end %>><%= escape_html(documentation_t('labels.api_versions')) %></a></li>
8
8
  <% if (reference = shared_documentation_reference_url) %>
9
- <li><a href="<%= escape_html(reference) %>">API reference</a></li>
10
- <li><a href="<%= escape_html(shared_documentation_reference_url(page: 'resources')) %>">Resources</a></li>
9
+ <li><a href="<%= escape_html(reference) %>"><%= escape_html(documentation_t('labels.api_reference')) %></a></li>
10
+ <li><a href="<%= escape_html(shared_documentation_reference_url(page: 'resources')) %>"><%= escape_html(documentation_t('labels.resources')) %></a></li>
11
11
  <% end %>
12
12
  </ul>
13
13
  </nav>
14
14
  <% if @documentation_toc && !@documentation_toc.empty? %>
15
- <nav aria-label="Contents" data-action-nav><%= @documentation_toc %></nav>
15
+ <nav aria-label="<%= escape_html(documentation_t('labels.contents')) %>" data-action-nav><%= @documentation_toc %></nav>
16
16
  <% end %>
17
- <nav aria-label="Shared documentation">
18
- <h2><a href="<%= escape_html(shared_documentation_url('doc')) %>">HaveAPI internals</a></h2>
17
+ <nav aria-label="<%= escape_html(documentation_t('accessibility.shared')) %>">
18
+ <h2><a href="<%= escape_html(shared_documentation_url('doc')) %>"><%= escape_html(documentation_t('articles.readme')) %></a></h2>
19
19
  <ul>
20
- <li><a href="<%= escape_html(shared_documentation_url('doc/protocol')) %>">Protocol</a></li>
21
- <li><a href="<%= escape_html(shared_documentation_url('doc/json-schema')) %>">JSON schema</a></li>
22
- <li><a href="<%= escape_html(shared_documentation_url('doc/create-client')) %>">Create a client</a></li>
23
- <li><a href="<%= escape_html(shared_documentation_url('doc/client-examples')) %>">Client examples</a></li>
20
+ <li><a href="<%= escape_html(shared_documentation_url('doc/protocol')) %>"><%= escape_html(documentation_t('articles.protocol')) %></a></li>
21
+ <li><a href="<%= escape_html(shared_documentation_url('doc/json-schema')) %>"><%= escape_html(documentation_t('articles.json_schema')) %></a></li>
22
+ <li><a href="<%= escape_html(shared_documentation_url('doc/create-client')) %>"><%= escape_html(documentation_t('articles.create_client')) %></a></li>
23
+ <li><a href="<%= escape_html(shared_documentation_url('doc/client-examples')) %>"><%= escape_html(documentation_t('articles.client_examples')) %></a></li>
24
24
  </ul>
25
25
  </nav>
@@ -6,31 +6,31 @@
6
6
 
7
7
  <% if name == :token %>
8
8
  <dl class="docs-metadata">
9
- <dt>HTTP header:</dt>
9
+ <dt><%= escape_html(documentation_t('labels.http_header')) %></dt>
10
10
  <dd><%= info[:http_header] %></dd>
11
- <dt>Query parameter:</dt>
11
+ <dt><%= escape_html(documentation_t('labels.query_parameter')) %></dt>
12
12
  <dd><%= info[:query_parameter] %></dd>
13
13
  </dl>
14
14
  <% elsif name == :oauth2 %>
15
15
  <dl class="docs-metadata">
16
- <dt>Authorize URL:</dt>
16
+ <dt><%= escape_html(documentation_t('labels.authorize_url')) %></dt>
17
17
  <dd><%= info[:authorize_url] %></dd>
18
- <dt>Token URL:</dt>
18
+ <dt><%= escape_html(documentation_t('labels.token_url')) %></dt>
19
19
  <dd><%= info[:token_url] %></dd>
20
- <dt>Revoke URL:</dt>
20
+ <dt><%= escape_html(documentation_t('labels.revoke_url')) %></dt>
21
21
  <dd><%= info[:revoke_url] %></dd>
22
22
  </dl>
23
23
  <% end %>
24
24
 
25
25
  <% unless (info[:resources] || {}).empty? %>
26
26
  <% resources_target = documentation_reference_anchor(authentication: name, section: :resources) %>
27
- <h2 id="<%= escape_html(resources_target) %>">Resources<%= documentation_permalink(resources_target, 'Resources') %></h2>
27
+ <h2 id="<%= escape_html(resources_target) %>"><%= escape_html(documentation_t('labels.resources')) %><%= documentation_permalink(resources_target, documentation_t('labels.resources')) %></h2>
28
28
  <% sort_hash(info[:resources]).each do |resource, desc| %>
29
29
  <%= erb :"version_page/resource_body", locals: {resource: resource.to_s, info: desc, path: [], prefix: 'root', name: nil, authentication_resource: true, authentication_provider: name} %>
30
30
  <% end %>
31
31
  <% end %>
32
32
 
33
33
  <% examples_target = documentation_reference_anchor(authentication: name, section: :examples) %>
34
- <h3 id="<%= escape_html(examples_target) %>">Examples<%= documentation_permalink(examples_target, 'Examples') %></h3>
34
+ <h3 id="<%= escape_html(examples_target) %>"><%= escape_html(documentation_t('labels.examples')) %><%= documentation_permalink(examples_target, documentation_t('labels.examples')) %></h3>
35
35
  <%= erb :'version_page/example_panels', locals: {baseid: "auth-#{name}", kind: :auth, changes: {auth_method: name, auth_description: info}} %>
36
36
  </section>
@@ -1,2 +1,2 @@
1
- <h4><%= escape_html(client.label) %></h4>
1
+ <h4><%= escape_html(documentation_client_label(client)) %></h4>
2
2
  <%= erb :"version_page/client_result", locals: {client: client, result: result} %>
@@ -1,2 +1,2 @@
1
- <h6><%= escape_html(client.label) %></h6>
1
+ <h6><%= escape_html(documentation_client_label(client)) %></h6>
2
2
  <%= erb :"version_page/client_result", locals: {client: client, result: result} %>
@@ -1,2 +1,2 @@
1
- <h4><%= escape_html(client.label) %></h4>
1
+ <h4><%= escape_html(documentation_client_label(client)) %></h4>
2
2
  <%= erb :"version_page/client_result", locals: {client: client, result: result} %>
@@ -19,7 +19,7 @@
19
19
  <% library_clients = clients.select { |client| library_paths.has_key?(client.id) || generator_paths.has_key?(client.id) } %>
20
20
  <% groups = library_clients.group_by { |client| client.language == 'cli' && library_clients.any? { |candidate| candidate.language == 'ruby' } ? 'ruby' : client.language } %>
21
21
  <section id="client-libraries">
22
- <h2>Client libraries<%= documentation_permalink('client-libraries', 'Client libraries') %></h2>
22
+ <h2><%= escape_html(documentation_t('labels.client_libraries')) %><%= documentation_permalink('client-libraries', documentation_t('labels.client_libraries')) %></h2>
23
23
  <ul>
24
24
  <% groups.each_value do |group| %>
25
25
  <% variants = group.length > 1 || group.first.variant %>
@@ -27,14 +27,16 @@
27
27
  <li>
28
28
  <% if variants %><%= escape_html(group.first.language_label) %> (<% end %><% group.each_with_index do |client, index|
29
29
  path = library_paths[client.id] || generator_paths.fetch(client.id)
30
- label = variants ? (client.variant&.downcase&.sub(/\Aapi\b/, 'API') || (client.language == 'ruby' ? 'library' : client.language_label)) : client.language_label
31
- separator = index.zero? ? '' : (index == group.length - 1 ? ' and ' : ', ')
32
- %><%= separator %><a href="<%= escape_html("https://github.com/vpsfreecz/haveapi/tree/master/#{path}") %>"><%= escape_html(label) %></a><% end %><% if variants %>)<% end %><% profiles.each do |profile| %>: <code><%= escape_html(profile.package_name) %></code><% unless profile.package_version.nil? %> <%= escape_html(profile.package_version) %><% end %><% end %>
30
+ variant = documentation_client_variant(client)
31
+ overview_variant = variant == client.variant ? variant&.downcase&.sub(/\Aapi\b/, 'API') : variant&.sub(/\A./) { |letter| letter.downcase }
32
+ label = variants ? (overview_variant || (client.language == 'ruby' ? documentation_t('client.library') : client.language_label)) : client.language_label
33
+ separator = index.zero? ? '' : (index == group.length - 1 ? documentation_t('client.and') : ', ')
34
+ %><%= escape_html(separator) %><a href="<%= escape_html("https://github.com/vpsfreecz/haveapi/tree/master/#{path}") %>"><%= escape_html(label) %></a><% end %><% if variants %>)<% end %><% profiles.each do |profile| %>: <code><%= escape_html(profile.package_name) %></code><% unless profile.package_version.nil? %> <%= escape_html(profile.package_version) %><% end %><% end %>
33
35
  </li>
34
36
  <% end %>
35
37
  </ul>
36
38
  <% request_formats = clients.select { |client| %w[curl http].include?(client.language) } %>
37
39
  <% unless request_formats.empty? %>
38
- <p><% request_formats.each_with_index do |client, index| %><%= index.zero? ? '' : ' and ' %><a href="<%= escape_html(documentation_url(page: 'resources')) %>"><%= escape_html(client.label) %></a><% end %> request examples are available on resource pages.</p>
40
+ <p><% request_formats.each_with_index do |client, index| %><%= escape_html(index.zero? ? '' : documentation_t('client.and')) %><a href="<%= escape_html(documentation_url(page: 'resources')) %>"><%= escape_html(client.label) %></a><% end %> <%= escape_html(documentation_t('client.request_examples')) %></p>
39
41
  <% end %>
40
42
  </section>
@@ -1,6 +1,8 @@
1
1
  <% legacy_baseid ||= nil %>
2
2
  <% variants = documentation_example_variants(kind, **changes) %>
3
3
  <% details_by_client = variants.group_by { |client, _detail, _result| client.id }.transform_values { |items| items.map { |_client, detail, _result| detail.to_s } } %>
4
+ <% selection = documentation_example_selection %>
5
+ <% selected_details = selection[:client] && details_by_client[selection[:client].id] %>
4
6
  <% if legacy_baseid %><%= documentation_reference_alias("#{legacy_baseid}-examples") %><% end %>
5
7
  <div class="docs-example" data-example data-example-details="<%= escape_html(JSON.generate(details_by_client)) %>" id="<%= escape_html("#{baseid}-examples") %>">
6
8
  <% variants.each do |client, detail, result| %>
@@ -10,9 +12,10 @@
10
12
  <%= documentation_reference_alias("#{legacy_baseid || baseid}-#{client.id}-thorough") %>
11
13
  <% if legacy_baseid %><%= documentation_reference_alias("#{baseid}-#{client.id}-thorough") %><% end %>
12
14
  <% end %>
13
- <details data-example-panel data-client="<%= escape_html(client.id) %>" data-language="<%= escape_html(client.language) %>" data-variant="<%= escape_html(client.variant) %>" data-detail="<%= detail %>" id="<%= escape_html("#{baseid}-#{client.id}#{suffix}") %>"<% if detail == :simple %> open<% end %>>
14
- <summary><%= escape_html(client.label) %> · <%= detail == :simple ? 'Simple' : 'With error handling' %></summary>
15
+ <details data-example-panel data-client="<%= escape_html(client.id) %>" data-language="<%= escape_html(client.language) %>" data-variant="<%= escape_html(client.variant) %>" data-detail="<%= detail %>" id="<%= escape_html("#{baseid}-#{client.id}#{suffix}") %>"<% if selection[:client] == client && detail.to_s == documentation_example_detail(details_by_client[client.id]) %> open<% end %>>
16
+ <summary><%= escape_html(documentation_client_label(client)) %> · <%= escape_html(documentation_t(detail == :simple ? 'labels.simple' : 'labels.thorough')) %></summary>
15
17
  <%= erb :'version_page/client_result', locals: {client: client, result: result} %>
16
18
  </details>
17
19
  <% end %>
20
+ <% unless selected_details %><p class="docs-notice" data-example-unavailable><%= escape_html(documentation_t('browser.example_unavailable')) %></p><% end %>
18
21
  </div>
@@ -20,34 +20,34 @@
20
20
  <<%= action_heading %>><%= escape_html(action.capitalize) %><%= documentation_permalink(action_target, action.to_s.capitalize) %></<%= action_heading %>>
21
21
  <div class="action">
22
22
  <dl class="docs-metadata">
23
- <dt>Path</dt><dd><%= info[:method] %> <%= info[:path] %></dd>
24
- <dt>Description</dt><dd><%= info[:description] %></dd>
25
- <dt>Authentication required</dt><dd><%= info[:auth] ? 'yes' : 'no' %></dd>
26
- <dt>Scope</dt><dd><%= info[:scope] %></dd>
27
- <dt>Aliases</dt><dd><%= info[:aliases].join(', ') %></dd>
28
- <dt>Blocking</dt><dd><%= info[:blocking] ? 'yes' : 'no' %></dd>
23
+ <dt><%= escape_html(documentation_t('labels.path')) %></dt><dd><%= info[:method] %> <%= info[:path] %></dd>
24
+ <dt><%= escape_html(documentation_t('labels.description')) %></dt><dd><%= info[:description] %></dd>
25
+ <dt><%= escape_html(documentation_t('labels.authentication_required')) %></dt><dd><%= escape_html(info[:auth] ? documentation_t('labels.yes') : documentation_t('labels.no')) %></dd>
26
+ <dt><%= escape_html(documentation_t('labels.scope')) %></dt><dd><%= info[:scope] %></dd>
27
+ <dt><%= escape_html(documentation_t('labels.aliases')) %></dt><dd><%= info[:aliases].join(', ') %></dd>
28
+ <dt><%= escape_html(documentation_t('labels.blocking')) %></dt><dd><%= escape_html(info[:blocking] ? documentation_t('labels.yes') : documentation_t('labels.no')) %></dd>
29
29
  </dl>
30
- <<%= parameter_heading %> id="<%= escape_html(sections[0][:id]) %>">Input parameters<%= documentation_permalink(sections[0][:id], 'Input parameters') %></<%= parameter_heading %>>
30
+ <<%= parameter_heading %> id="<%= escape_html(sections[0][:id]) %>"><%= escape_html(documentation_t('labels.input_parameters')) %><%= documentation_permalink(sections[0][:id], documentation_t('labels.input_parameters')) %></<%= parameter_heading %>>
31
31
  <% if info[:input][:parameters].empty? %>
32
- <p>No parameters.</p>
32
+ <p><%= escape_html(documentation_t('labels.no_parameters')) %></p>
33
33
  <% else %>
34
34
  <dl class="docs-metadata">
35
- <dt>Layout</dt><dd><%= info[:input][:layout] %></dd>
36
- <dt>Namespace</dt><dd><%= info[:input][:namespace] %></dd>
35
+ <dt><%= escape_html(documentation_t('labels.layout')) %></dt><dd><%= info[:input][:layout] %></dd>
36
+ <dt><%= escape_html(documentation_t('labels.namespace')) %></dt><dd><%= info[:input][:namespace] %></dd>
37
37
  </dl>
38
- <div class="docs-table-scroll" tabindex="0" role="region" aria-label="Input parameters">
38
+ <div class="docs-table-scroll" tabindex="0" role="region" aria-label="<%= escape_html(documentation_t('labels.input_parameters')) %>">
39
39
  <table class="docs-input-parameters">
40
- <thead><tr><th>Parameter</th><th>Type</th><th>Required</th><th>Details</th></tr></thead>
40
+ <thead><tr><th><%= escape_html(documentation_t('labels.parameter')) %></th><th><%= escape_html(documentation_t('labels.type')) %></th><th><%= escape_html(documentation_t('labels.required')) %></th><th><%= escape_html(documentation_t('labels.details')) %></th></tr></thead>
41
41
  <tbody>
42
42
  <% info[:input][:parameters].each do |param, parameter| %>
43
43
  <tr id="<%= escape_html(documentation_parameter_anchor(resource_path: resource_path, action_name: action, direction: :input, parameter_name: param, authentication: authentication_provider)) %>">
44
44
  <td class="docs-param-name"><code><%= escape_html(param) %></code><% if parameter[:label].to_s != param.to_s %><div><%= parameter[:label] %></div><% end %></td>
45
45
  <td><%= format_param_type(parameter) %></td>
46
- <td><%= parameter[:required] ? 'yes' : 'no' %></td>
46
+ <td><%= escape_html(parameter[:required] ? documentation_t('labels.yes') : documentation_t('labels.no')) %></td>
47
47
  <td class="docs-param-details">
48
48
  <% if parameter[:description] %><p><%= escape_html(parameter[:description]) %></p><% end %>
49
49
  <% if parameter.has_key?(:default) && parameter[:default] != :_nil %>
50
- <p><strong>Default:</strong> <code><%= escape_html(parameter[:default].nil? ? 'null' : parameter[:default] == '' ? '""' : parameter[:default]) %></code></p>
50
+ <p><strong><%= escape_html(documentation_t('labels.default')) %></strong> <code><%= escape_html(parameter[:default].nil? ? 'null' : parameter[:default] == '' ? '""' : parameter[:default]) %></code></p>
51
51
  <% end %>
52
52
  <%= format_validators(parameter[:validators], type: parameter[:type]) %>
53
53
  </td>
@@ -57,17 +57,17 @@
57
57
  </table>
58
58
  </div>
59
59
  <% end %>
60
- <<%= parameter_heading %> id="<%= escape_html(sections[1][:id]) %>">Output parameters<%= documentation_permalink(sections[1][:id], 'Output parameters') %></<%= parameter_heading %>>
60
+ <<%= parameter_heading %> id="<%= escape_html(sections[1][:id]) %>"><%= escape_html(documentation_t('labels.output_parameters')) %><%= documentation_permalink(sections[1][:id], documentation_t('labels.output_parameters')) %></<%= parameter_heading %>>
61
61
  <% if info[:output][:parameters].empty? && info[:output][:format].nil? %>
62
- <p>No parameters.</p>
62
+ <p><%= escape_html(documentation_t('labels.no_parameters')) %></p>
63
63
  <% else %>
64
64
  <dl class="docs-metadata">
65
- <dt>Layout</dt><dd><%= info[:output][:layout] %></dd>
66
- <dt>Namespace</dt><dd><%= info[:output][:namespace] %></dd>
65
+ <dt><%= escape_html(documentation_t('labels.layout')) %></dt><dd><%= info[:output][:layout] %></dd>
66
+ <dt><%= escape_html(documentation_t('labels.namespace')) %></dt><dd><%= info[:output][:namespace] %></dd>
67
67
  </dl>
68
- <div class="docs-table-scroll" tabindex="0" role="region" aria-label="Output parameters">
68
+ <div class="docs-table-scroll" tabindex="0" role="region" aria-label="<%= escape_html(documentation_t('labels.output_parameters')) %>">
69
69
  <table class="docs-output-parameters">
70
- <thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead>
70
+ <thead><tr><th><%= escape_html(documentation_t('labels.parameter')) %></th><th><%= escape_html(documentation_t('labels.type')) %></th><th><%= escape_html(documentation_t('labels.description')) %></th></tr></thead>
71
71
  <tbody>
72
72
  <% info[:output][:parameters].each do |param, parameter| %>
73
73
  <tr id="<%= escape_html(documentation_parameter_anchor(resource_path: resource_path, action_name: action, direction: :output, parameter_name: param, authentication: authentication_provider)) %>">
@@ -81,10 +81,10 @@
81
81
  </div>
82
82
  <% end %>
83
83
  <% unless info[:examples].empty? %>
84
- <<%= parameter_heading %> id="<%= escape_html(sections[2][:id]) %>">Examples<%= documentation_permalink(sections[2][:id], 'Examples') %></<%= parameter_heading %>>
85
- <p>Examples use an initialized <code>api</code> client, authenticated when required. See <a href="<%= escape_html(documentation_url(anchor: 'initialization')) %>">initialization</a> and <a href="<%= escape_html(documentation_url(page: 'authentication')) %>">authentication</a>.</p>
84
+ <<%= parameter_heading %> id="<%= escape_html(sections[2][:id]) %>"><%= escape_html(documentation_t('labels.examples')) %><%= documentation_permalink(sections[2][:id], documentation_t('labels.examples')) %></<%= parameter_heading %>>
85
+ <p><%= escape_html(documentation_t('example.initialized')) %> <%= escape_html(documentation_t('example.see')) %> <a href="<%= escape_html(documentation_url(anchor: 'initialization')) %>"><%= escape_html(documentation_t('example.initialization')) %></a> <%= escape_html(documentation_t('example.and')) %> <a href="<%= escape_html(documentation_url(page: 'authentication')) %>"><%= escape_html(documentation_t('example.authentication')) %></a>.</p>
86
86
  <% info[:examples].each_with_index do |example, index| %>
87
- <% example_title = example[:title].empty? ? "Example ##{index}" : example[:title] %>
87
+ <% example_title = example[:title].empty? ? documentation_t('example.title', index: index) : example[:title] %>
88
88
  <% example_target = documentation_reference_anchor(resource_path: resource_path, action_name: action, authentication: authentication_provider, section: :example_title, example_index: index) %>
89
89
  <h4 id="<%= escape_html(example_target) %>"><%= escape_html(example_title) %><%= documentation_permalink(example_target, example_title) %></h4>
90
90
  <p><%= example[:comment] %></p>
@@ -99,7 +99,7 @@
99
99
  </div>
100
100
  <% unless info[:resources].empty? %>
101
101
  <% children_target = documentation_reference_anchor(resource_path: resource_path, authentication: authentication_provider, section: :children) %>
102
- <h2 id="<%= escape_html(children_target) %>">Subresources<%= documentation_permalink(children_target, 'Subresources') %></h2>
102
+ <h2 id="<%= escape_html(children_target) %>"><%= escape_html(documentation_t('labels.subresources')) %><%= documentation_permalink(children_target, documentation_t('labels.subresources')) %></h2>
103
103
  <% if authentication_resource %>
104
104
  <% sort_hash(info[:resources]).each do |child, child_info| %>
105
105
  <%= erb :'version_page/resource_body', locals: {resource: child, info: child_info, path: resource_path, prefix: "#{prefix}-#{resource}", name: "#{name} / #{child.humanize}", authentication_resource: true, authentication_provider: authentication_provider} %>
@@ -1,7 +1,7 @@
1
1
  <section id="resources">
2
- <h1>Resources<%= documentation_permalink('resources', 'Resources') %></h1>
2
+ <h1><%= escape_html(documentation_t('labels.resources')) %><%= documentation_permalink('resources', documentation_t('labels.resources')) %></h1>
3
3
  <% if documentation_search_query.empty? %>
4
- <nav aria-label="Resources" data-resource-nav>
4
+ <nav aria-label="<%= escape_html(documentation_t('labels.resources')) %>" data-resource-nav>
5
5
  <ul class="docs-resource-list docs-resource-directory">
6
6
  <% sort_hash(@help[:resources]).each do |resource, info| %>
7
7
  <%= erb :'version_sidebar/resource_nav', locals: {resource: resource, info: info, path: []} %>
@@ -1,7 +1,7 @@
1
1
  <section aria-labelledby="reference-usage">
2
- <h2 id="reference-usage">Using this reference<%= documentation_permalink('reference-usage', 'Using this reference') %></h2>
3
- <p>Choose a <strong>Language</strong> and <strong>Client</strong> variant for the examples. <strong>Examples</strong> offers the selected client's supported formats. Your choices apply to every example and stay selected as you browse.</p>
4
- <p>Start with <a href="#initialization">Initialization</a> below and <a href="<%= escape_html(documentation_url(page: 'authentication')) %>">Authentication</a> for credentials. Open <a href="<%= escape_html(documentation_url(page: 'resources')) %>">Resources</a> to browse the API, then choose a resource to see its actions, parameters and examples.</p>
5
- <p>Search finds resources, actions and input or output parameters. Follow a result to its reference entry.</p>
6
- <p>While signed out, the reference shows all declared resources, actions and parameters.<% if documentation_account_context&.dig(:controls) %> Sign in to show only those available to your account.<% end %> Each API request still checks permissions for the requested operation.</p>
2
+ <h2 id="reference-usage"><%= escape_html(documentation_t('labels.usage')) %><%= documentation_permalink('reference-usage', documentation_t('labels.usage')) %></h2>
3
+ <p><%= escape_html(documentation_t('usage.choose')) %></p>
4
+ <p><%= escape_html(documentation_t('usage.start')) %> <a href="#initialization"><%= escape_html(documentation_t('labels.initialization')) %></a> <%= escape_html(documentation_t('usage.below')) %> <a href="<%= escape_html(documentation_url(page: 'authentication')) %>"><%= escape_html(documentation_t('labels.authentication')) %></a> <%= escape_html(documentation_t('usage.credentials')) %> <a href="<%= escape_html(documentation_url(page: 'resources')) %>"><%= escape_html(documentation_t('labels.resources')) %></a> <%= escape_html(documentation_t('usage.browse')) %></p>
5
+ <p><%= escape_html(documentation_t('usage.search')) %></p>
6
+ <p><%= escape_html(documentation_t('usage.signed_out')) %><% if documentation_account_context&.dig(:controls) %> <%= escape_html(documentation_t('usage.sign_in')) %><% end %></p>
7
7
  </section>
@@ -1,30 +1,30 @@
1
1
  <% if @documentation_page == 'overview' %>
2
2
  <h1 id="api">API v<%= escape_html(@v) %><%= documentation_permalink('api', "API v#{@v}") %></h1>
3
3
  <%= erb :'version_page/usage' %>
4
- <p>Connect to <code><%= escape_html("#{base_url}#{root}") %></code> with a <a href="https://github.com/vpsfreecz/haveapi">HaveAPI client</a>.</p>
4
+ <p><%= escape_html(documentation_t('overview.api_address')) %> <code><%= escape_html("#{base_url}#{root}") %></code>.</p>
5
5
  <%= erb :'version_page/client_overview' %>
6
- <p>Examples target API v<%= escape_html(@v) %>. API clients use their own package versions and must match this API.</p>
6
+ <p><%= escape_html(documentation_t('overview.versions', version: @v)) %></p>
7
7
  <section id="initialization" data-doc-section>
8
- <h2>Initialization<%= documentation_permalink('initialization', 'Initialization') %></h2>
9
- <p>Initialize your client, then follow the <a href="<%= escape_html(documentation_url(page: 'authentication')) %>">authentication instructions</a> when credentials are required.</p>
8
+ <h2><%= escape_html(documentation_t('labels.initialization')) %><%= documentation_permalink('initialization', documentation_t('labels.initialization')) %></h2>
9
+ <p><%= escape_html(documentation_t('overview.initialize_before')) %> <a href="<%= escape_html(documentation_url(page: 'authentication')) %>"><%= escape_html(documentation_t('overview.authentication_link')) %></a> <%= escape_html(documentation_t('overview.initialize_after')) %></p>
10
10
  <%= erb :'version_page/example_panels', locals: {baseid: 'init', kind: :init, changes: {}} %>
11
11
  </section>
12
- <p><a href="<%= escape_html(documentation_url(page: 'resources')) %>" data-resource-directory-link>Browse all resources</a> to find their actions, parameters and examples.</p>
12
+ <p><a href="<%= escape_html(documentation_url(page: 'resources')) %>" data-resource-directory-link><%= escape_html(documentation_t('overview.browse_link')) %></a> <%= escape_html(documentation_t('overview.browse_after')) %></p>
13
13
  <% elsif @documentation_page == 'resources' %>
14
14
  <%= erb :'version_page/resource_directory' %>
15
15
  <% elsif @documentation_page == 'authentication' %>
16
- <nav aria-label="Breadcrumb"><ol><li><a href="<%= escape_html(documentation_url) %>">Overview</a></li><li aria-current="page">Authentication</li></ol></nav>
17
- <h1 id="auth">Authentication<%= documentation_permalink('auth', 'Authentication') %></h1>
18
- <p>Initialize your client using the <a href="<%= escape_html(documentation_url(anchor: 'initialization')) %>">overview examples</a>, then choose an authentication method.</p>
19
- <% if @help[:authentication].empty? %><p>Authentication is disabled for this API.</p><% end %>
16
+ <nav class="docs-breadcrumb" aria-label="<%= escape_html(documentation_t('accessibility.breadcrumb')) %>"><ol><li><a href="<%= escape_html(documentation_url) %>"><%= escape_html(documentation_t('labels.overview')) %></a></li><li aria-current="page"><%= escape_html(documentation_t('labels.authentication')) %></li></ol></nav>
17
+ <h1 id="auth"><%= escape_html(documentation_t('labels.authentication')) %><%= documentation_permalink('auth', documentation_t('labels.authentication')) %></h1>
18
+ <p><%= escape_html(documentation_t('authentication.initialize_before')) %> <a href="<%= escape_html(documentation_url(anchor: 'initialization')) %>"><%= escape_html(documentation_t('authentication.overview_link')) %></a><%= escape_html(documentation_t('authentication.initialize_after')) %></p>
19
+ <% if @help[:authentication].empty? %><p><%= escape_html(documentation_t('authentication.disabled')) %></p><% end %>
20
20
  <% @help[:authentication].each do |name, info| %>
21
21
  <%= erb :'version_page/auth_body', locals: {name: name, info: info} %>
22
22
  <% end %>
23
23
  <% else %>
24
24
  <% entry = @documentation_resource %>
25
- <nav aria-label="Breadcrumb" data-resource-breadcrumbs>
25
+ <nav class="docs-breadcrumb" aria-label="<%= escape_html(documentation_t('accessibility.breadcrumb')) %>" data-resource-breadcrumbs>
26
26
  <ol>
27
- <li><a href="<%= escape_html(documentation_url(page: 'resources')) %>">Resources</a></li>
27
+ <li><a href="<%= escape_html(documentation_url(page: 'resources')) %>"><%= escape_html(documentation_t('labels.resources')) %></a></li>
28
28
  <% entry[:path].each_with_index do |part, index| %>
29
29
  <% if index == entry[:path].length - 1 %>
30
30
  <li aria-current="page"><%= escape_html(part.humanize) %></li>
@@ -5,11 +5,11 @@
5
5
  <a data-doc-primary href="#<%= escape_html(target) %>"><%= escape_html(method.to_s.humanize) %></a>
6
6
  <ul data-doc-subnav="<%= escape_html(target) %>">
7
7
  <% unless (info[:resources] || {}).empty? %>
8
- <li><a data-doc-subsection href="#<%= escape_html(documentation_reference_anchor(authentication: method, section: :resources)) %>">Resources</a>
8
+ <li><a data-doc-subsection href="#<%= escape_html(documentation_reference_anchor(authentication: method, section: :resources)) %>"><%= escape_html(documentation_t('labels.resources')) %></a>
9
9
  <%= erb :'version_sidebar/auth_resource_nav', locals: {resources: info[:resources], path: [], authentication_provider: method} %>
10
10
  </li>
11
11
  <% end %>
12
- <li><a data-doc-subsection href="#<%= escape_html(documentation_reference_anchor(authentication: method, section: :examples)) %>">Examples</a></li>
12
+ <li><a data-doc-subsection href="#<%= escape_html(documentation_reference_anchor(authentication: method, section: :examples)) %>"><%= escape_html(documentation_t('labels.examples')) %></a></li>
13
13
  </ul>
14
14
  </li>
15
15
  <% end %>
@@ -3,23 +3,23 @@
3
3
  <div class="authentication">
4
4
  <% if account[:user] && controls[:signed_in] %>
5
5
  <div class="docs-account-content">
6
- <span class="sr-only">Account </span><span class="docs-identity"><%= escape_html(account[:user].login) %></span>
7
- <form method="post" action="<%= escape_html(controls[:logout_url]) %>">
8
- <input type="hidden" name="csrf" value="<%= escape_html(controls[:csrf_token]) %>">
9
- <button type="submit">Sign out</button>
10
- </form>
6
+ <span class="sr-only"><%= escape_html(documentation_t('labels.account')) %> </span><span class="docs-identity"><%= escape_html(account[:user].login) %></span>
11
7
  <% if controls[:switch_user] %>
12
8
  <form method="post" action="<%= escape_html(controls[:logout_url]) %>">
13
9
  <input type="hidden" name="csrf" value="<%= escape_html(controls[:csrf_token]) %>">
14
10
  <input type="hidden" name="switch_user" value="1">
15
- <button type="submit">Switch user</button>
11
+ <button type="submit"><%= escape_html(documentation_t('labels.switch_user')) %></button>
16
12
  </form>
17
13
  <% end %>
14
+ <form method="post" action="<%= escape_html(controls[:logout_url]) %>">
15
+ <input type="hidden" name="csrf" value="<%= escape_html(controls[:csrf_token]) %>">
16
+ <button type="submit"><%= escape_html(documentation_t('labels.sign_out')) %></button>
17
+ </form>
18
18
  </div>
19
19
  <% else %>
20
- <a class="docs-sign-in" href="<%= escape_html(controls[:login_url]) %>" data-documentation-login aria-label="Sign in" title="Sign in">
20
+ <a class="docs-sign-in" href="<%= escape_html(controls[:login_url]) %>" data-documentation-login aria-label="<%= escape_html(documentation_t('labels.sign_in')) %>" title="<%= escape_html(documentation_t('labels.sign_in')) %>">
21
21
  <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="8" r="4"></circle><path d="M4 21v-2a8 8 0 0 1 16 0v2"></path></svg>
22
- <span>Sign in</span>
22
+ <span><%= escape_html(documentation_t('labels.sign_in')) %></span>
23
23
  </a>
24
24
  <% end %>
25
25
  </div>
@@ -1,3 +1,3 @@
1
1
  <% controls = account[:controls] %>
2
- <p class="docs-visibility-note"><%= account[:user] ? 'Showing resources, actions and parameters available to this account.' : 'Showing all resources, actions and parameters.' %></p>
2
+ <p class="docs-visibility-note"><%= escape_html(documentation_t(account[:user] ? 'visibility.account' : 'visibility.all')) %></p>
3
3
  <% if controls && controls[:message] %><p role="status"><%= escape_html(controls[:message]) %></p><% end %>
@@ -2,14 +2,25 @@
2
2
  <a href="<%= escape_html(url(root, false)) %>"><%= escape_html(documentation_identity_name) %></a>
3
3
  <% if @v %><small class="docs-api-version">API v<%= escape_html(@v) %></small><% end %>
4
4
  <details data-documentation-menu>
5
- <summary aria-label="Documentation settings" title="Documentation settings">
5
+ <summary aria-label="<%= escape_html(documentation_t('labels.settings')) %>" title="<%= escape_html(documentation_t('labels.settings')) %>">
6
6
  <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="2"><path d="m9.5 3-.5 2.1-1.7 1-2.1-.6-2.5 4.3 1.6 1.5v2l-1.6 1.5 2.5 4.3 2.1-.6 1.7 1 .5 2.1h5l.5-2.1 1.7-1 2.1.6 2.5-4.3-1.6-1.5v-2l1.6-1.5-2.5-4.3-2.1.6-1.7-1L14.5 3Z"></path><circle cx="12" cy="12" r="3"></circle></svg>
7
7
  </summary>
8
8
  <div data-documentation-menu-content>
9
- <span id="docs-theme-label" class="docs-theme-label">Theme</span>
9
+ <form data-documentation-language method="get" action="<%= escape_html(request.path) %>">
10
+ <% documentation_language_parameters.each do |key, value| %>
11
+ <input type="hidden" name="<%= escape_html(key) %>" value="<%= escape_html(value) %>">
12
+ <% end %>
13
+ <label for="docs-language"><%= escape_html(documentation_t('labels.language')) %></label>
14
+ <select id="docs-language" name="doc_lang">
15
+ <option value="en"<% if documentation_locale == 'en' %> selected<% end %>>English</option>
16
+ <option value="cs"<% if documentation_locale == 'cs' %> selected<% end %>>Česky</option>
17
+ </select>
18
+ <button type="submit" data-documentation-language-submit><%= escape_html(documentation_t('labels.apply_language')) %></button>
19
+ </form>
20
+ <span id="docs-theme-label" class="docs-theme-label"><%= escape_html(documentation_t('labels.theme')) %></span>
10
21
  <div class="docs-theme-choices" role="group" aria-labelledby="docs-theme-label">
11
- <% {auto: 'Automatic theme', light: 'Light theme', dark: 'Dark theme'}.each do |choice, label| %>
12
- <button type="button" data-theme-choice="<%= choice %>" aria-label="<%= label %>" title="<%= label %>" aria-pressed="<%= choice == :auto %>">
22
+ <% {auto: 'labels.theme_auto', light: 'labels.theme_light', dark: 'labels.theme_dark'}.each do |choice, label| %>
23
+ <button type="button" data-theme-choice="<%= choice %>" aria-label="<%= escape_html(documentation_t(label)) %>" title="<%= escape_html(documentation_t(label)) %>" aria-pressed="<%= choice == :auto %>">
13
24
  <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="2">
14
25
  <% if choice == :auto %><circle cx="12" cy="12" r="8"></circle><path d="M12 4a8 8 0 0 0 0 16Z" fill="currentColor"></path>
15
26
  <% elsif choice == :light %><circle cx="12" cy="12" r="4"></circle><path d="M12 2v2m0 16v2M2 12h2m16 0h2M5 5l2 2m10 10 2 2M5 19l2-2M17 7l2-2"></path>
@@ -21,7 +32,7 @@
21
32
  <% if account %>
22
33
  <%= erb :'version_sidebar/authentication_control', locals: {account: account} %>
23
34
  <% elsif (account_url = documentation_neutral_account_url) %>
24
- <a class="docs-account-link" href="<%= escape_html(account_url) %>" aria-label="Account" title="Account"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="8" r="4"></circle><path d="M4 21v-2a8 8 0 0 1 16 0v2"></path></svg><span>Account</span></a>
35
+ <a class="docs-account-link" href="<%= escape_html(account_url) %>" aria-label="<%= escape_html(documentation_t('labels.account')) %>" title="<%= escape_html(documentation_t('labels.account')) %>"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="8" r="4"></circle><path d="M4 21v-2a8 8 0 0 1 16 0v2"></path></svg><span><%= escape_html(documentation_t('labels.account')) %></span></a>
25
36
  <% end %>
26
37
  </div>
27
38
  </details>
@@ -2,22 +2,22 @@
2
2
  <% if (search_options = documentation_search_form_options(id: 'docs-search-sidebar')) %>
3
3
  <%= erb :'documentation/search_form', locals: search_options %>
4
4
  <% end %>
5
- <nav aria-label="Documentation pages">
5
+ <nav aria-label="<%= escape_html(documentation_t('accessibility.pages')) %>">
6
6
  <ul>
7
- <li><a href="<%= escape_html(documentation_url) %>"<% if @documentation_page == 'overview' %> aria-current="page"<% end %>>Overview</a></li>
7
+ <li><a href="<%= escape_html(documentation_url) %>"<% if @documentation_page == 'overview' %> aria-current="page"<% end %>><%= escape_html(documentation_t('labels.overview')) %></a></li>
8
8
  <li>
9
- <a href="<%= escape_html(documentation_url(page: 'authentication')) %>"<% if @documentation_page == 'authentication' %> aria-current="page"<% end %>>Authentication</a>
9
+ <a href="<%= escape_html(documentation_url(page: 'authentication')) %>"<% if @documentation_page == 'authentication' %> aria-current="page"<% end %>><%= escape_html(documentation_t('labels.authentication')) %></a>
10
10
  <% if @documentation_page == 'authentication' %>
11
- <nav aria-label="Authentication methods" data-action-nav><%= erb :'version_sidebar/auth_nav', locals: {methods: @help[:authentication]} %></nav>
11
+ <nav aria-label="<%= escape_html(documentation_t('accessibility.authentication_methods')) %>" data-action-nav><%= erb :'version_sidebar/auth_nav', locals: {methods: @help[:authentication]} %></nav>
12
12
  <% end %>
13
13
  </li>
14
- <li><a href="<%= escape_html(documentation_url(page: 'resources')) %>"<% if @documentation_page == 'resources' %> aria-current="page"<% end %> data-resource-directory-link>Resources</a></li>
14
+ <li><a href="<%= escape_html(documentation_url(page: 'resources')) %>"<% if @documentation_page == 'resources' %> aria-current="page"<% end %> data-resource-directory-link><%= escape_html(documentation_t('labels.resources')) %></a></li>
15
15
  </ul>
16
16
  </nav>
17
17
  <% if @documentation_resource %>
18
18
  <p data-current-resource><a href="<%= escape_html(documentation_url(resource: @documentation_resource[:key])) %>"><strong><%= escape_html(@documentation_resource[:key]) %></strong></a></p>
19
- <nav aria-label="Actions on this resource" data-action-nav>
20
- <h2>Actions</h2>
19
+ <nav aria-label="<%= escape_html(documentation_t('accessibility.resource_actions')) %>" data-action-nav>
20
+ <h2><%= escape_html(documentation_t('labels.actions')) %></h2>
21
21
  <ul class="docs-action-list">
22
22
  <% sort_hash(@documentation_resource[:info][:actions]).each do |action, info| %>
23
23
  <% target = documentation_resource_target(resource_path: @documentation_resource[:path], action_name: action) %>
@@ -33,8 +33,8 @@
33
33
  </ul>
34
34
  </nav>
35
35
  <% unless @documentation_resource[:info][:resources].empty? %>
36
- <nav aria-label="Subresources">
37
- <h2>Subresources</h2>
36
+ <nav aria-label="<%= escape_html(documentation_t('labels.subresources')) %>">
37
+ <h2><%= escape_html(documentation_t('labels.subresources')) %></h2>
38
38
  <ul>
39
39
  <% sort_hash(@documentation_resource[:info][:resources]).each do |child, _child_info| %>
40
40
  <% child_path = @documentation_resource[:path] + [child.to_s] %>
@@ -44,17 +44,32 @@
44
44
  </nav>
45
45
  <% end %>
46
46
  <% end %>
47
- <div class="docs-preferences">
48
- <label>Language <select data-language-select>
49
- <% documentation_client_metadata.uniq { |client| client[:language] }.each do |client| %>
50
- <option value="<%= escape_html(client[:language]) %>"><%= escape_html(client[:language_label]) %></option>
47
+ <% selection = documentation_example_selection %>
48
+ <% if selection[:client] %>
49
+ <% metadata = documentation_client_metadata %>
50
+ <% variants = metadata.select { |entry| entry[:language] == selection[:language] } %>
51
+ <% levels = metadata.find { |entry| entry[:id] == selection[:client].id }.fetch(:details) %>
52
+ <% detail = documentation_example_detail(levels) %>
53
+ <form class="docs-preferences" data-example-preferences method="get" action="<%= escape_html(request.path) %>"<% if selection[:explicit] %> data-example-selection="<%= escape_html(documentation_json(language: selection[:language], client: selection[:client].id, detail:)) %>"<% end %>>
54
+ <% documentation_example_form_parameters.each do |key, value| %>
55
+ <input type="hidden" name="<%= escape_html(key) %>" value="<%= escape_html(value) %>">
56
+ <% end %>
57
+ <label><%= escape_html(documentation_t('labels.programming_language')) %> <select data-language-select name="example_language">
58
+ <% metadata.uniq { |entry| entry[:language] }.each do |entry| %>
59
+ <option value="<%= escape_html(entry[:language]) %>"<% if entry[:language] == selection[:language] %> selected<% end %>><%= escape_html(entry[:language_label]) %></option>
51
60
  <% end %>
52
61
  </select></label>
53
- <label data-variant-control>Client <select data-variant-select>
54
- <% documentation_clients.each do |client| %>
55
- <option value="<%= escape_html(client.id) %>"><%= escape_html(client.variant || client.language_label) %></option>
62
+ <label data-variant-control><%= escape_html(documentation_t('labels.client')) %> <select data-variant-select name="example_client"<% if variants.length < 2 %> disabled<% end %>>
63
+ <% variants.each do |entry| %>
64
+ <option value="<%= escape_html(entry[:id]) %>"<% if entry[:id] == selection[:client].id %> selected<% end %>><%= escape_html(entry[:variant] || entry[:language_label]) %></option>
56
65
  <% end %>
57
66
  </select></label>
58
- <label data-detail-control>Examples <select data-detail-select><option value="simple">Simple</option><option value="thorough">With error handling</option></select></label>
67
+ <% if variants.length < 2 %><input type="hidden" name="example_client" value="<%= escape_html(selection[:client].id) %>"><% end %>
68
+ <label data-detail-control<% if levels.length < 2 %> hidden<% end %>><%= escape_html(documentation_t('labels.examples')) %> <select data-detail-select name="example_detail"<% if levels.length < 2 %> disabled<% end %>>
69
+ <% levels.each do |level| %><option value="<%= escape_html(level) %>"<% if level == detail %> selected<% end %>><%= escape_html(documentation_t(level == 'thorough' ? 'labels.thorough' : 'labels.simple')) %></option><% end %>
70
+ </select></label>
71
+ <% if levels.length < 2 %><input type="hidden" name="example_detail" value="<%= escape_html(detail) %>"><% end %>
72
+ <button type="submit" data-apply-examples><%= escape_html(documentation_t('labels.apply_examples')) %></button>
59
73
  <p data-preference-status role="status"></p>
60
- </div>
74
+ </form>
75
+ <% end %>