Skip to content
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

Language #16

Closed
wants to merge 5 commits into from
Closed

Language #16

wants to merge 5 commits into from

Conversation

maehr
Copy link
Member

@maehr maehr commented Feb 5, 2024

Pull request

Proposed changes

Types of changes

  • New feature (non-breaking change which adds functionality).
  • Enhancement (non-breaking change which enhances functionality)
  • Bug Fix (non-breaking change which fixes an issue).
  • Breaking change (fix or feature that would cause existing functionality to change).

Checklist

  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

  • New Features
    • Enhanced localization across the site, including dynamic translations for modal titles, descriptions, button labels, metadata fields, fallback messages, navigation menu links, PDF and video text, footer text, carousel controls, download links, page titles, and more.
    • Added dynamic content references in infographic layouts.
    • Introduced translated placeholders, aria-labels, and titles for search fields, buttons, and scroll-to-top functionality.
    • Implemented language-specific updates for DataTables and other interactive elements.
  • Documentation
    • Provided guidance on changing GUI element languages through configuration adjustments.
  • Bug Fixes
    • Adjusted formatting for timeline view button link.
  • Refactor
    • Updated the lang attribute and meta tags to use dynamic language settings, improving SEO and accessibility.

Copy link

changeset-bot bot commented Feb 5, 2024

⚠️ No Changeset found

Latest commit: 0be6f0d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

coderabbitai bot commented Feb 5, 2024

Walkthrough

The updates across various files primarily focus on enhancing the multilingual capabilities of a website by dynamically populating content based on language settings. These changes include updating text for modals, navigation menus, audio/video messages, footer, metadata, carousel controls, download links, and more to support translations, thereby improving localization and accessibility for users speaking different languages.

Changes

Files Change Summary
_includes/.../data-download-modal.html, _includes/index/data-download.html Updated to dynamically populate download modal and link texts with translations.
_includes/feature/audio.html, _includes/item/audio-player.html, _includes/feature/video.html, _includes/item/video-player.html Updated fallback messages for unsupported audio/video elements to use language-specific translations.
_includes/feature/nav-menu.html, _includes/index/objects.html, _includes/item/browse-buttons.html Updated link labels and button texts based on language settings.
_includes/feature/pdf.html, _includes/footer.html, _includes/head/head.html, _includes/head/item-meta.html, _includes/head/page-meta.html Enhanced localization by using dynamic translations for content and meta tags.
_includes/index/..., _includes/item/..., _layouts/... Various updates to dynamically populate text content using translation data for improved localization.
_includes/js/... Introduced variables for translated strings and updated logic to include these translations in scripts.
_layouts/data.html, _layouts/default.html, _layouts/timeline.html Updated to dynamically use translated labels and language settings.

Related issues

  • Multilingual site option #9: The changes in this PR directly support the objective of creating a multilingual site option by dynamically updating content based on language settings, as outlined in the referenced issue.

Poem

"In a world so wide and vast,
Our words, in many tongues, are cast.
🌍🐰 From code to verse, we leap and bound,
In every language, understanding found."

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 8

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f3dc0a9 and 0be6f0d.
Files ignored due to path filters (3)
  • _config.yml is excluded by: !**/*.yml
  • _data/translations.yml is excluded by: !**/*.yml
  • assets/lib/datatables/de.json is excluded by: !**/*.json
Files selected for processing (34)
  • _includes/data-download-modal.html (1 hunks)
  • _includes/feature/audio.html (1 hunks)
  • _includes/feature/nav-menu.html (1 hunks)
  • _includes/feature/pdf.html (1 hunks)
  • _includes/feature/video.html (1 hunks)
  • _includes/footer.html (2 hunks)
  • _includes/head/head.html (1 hunks)
  • _includes/head/item-meta.html (2 hunks)
  • _includes/head/page-meta.html (2 hunks)
  • _includes/index/carousel.html (2 hunks)
  • _includes/index/data-download.html (1 hunks)
  • _includes/index/description.html (1 hunks)
  • _includes/index/objects.html (1 hunks)
  • _includes/index/time.html (1 hunks)
  • _includes/item/audio-player.html (1 hunks)
  • _includes/item/breadcrumbs.html (1 hunks)
  • _includes/item/browse-buttons.html (1 hunks)
  • _includes/item/citation-box.html (1 hunks)
  • _includes/item/download-buttons.html (1 hunks)
  • _includes/item/image-gallery.html (1 hunks)
  • _includes/item/rights-box.html (1 hunks)
  • _includes/item/video-player.html (1 hunks)
  • _includes/js/browse-js.html (2 hunks)
  • _includes/js/lunr-js.html (2 hunks)
  • _includes/js/table-js.html (2 hunks)
  • _includes/nav-search-lunr.html (1 hunks)
  • _includes/scroll-to-top.html (1 hunks)
  • _layouts/browse.html (2 hunks)
  • _layouts/data.html (1 hunks)
  • _layouts/default.html (1 hunks)
  • _layouts/home-infographic.html (1 hunks)
  • _layouts/search.html (3 hunks)
  • _layouts/timeline.html (1 hunks)
  • docs/advanced_theme.md (1 hunks)
Additional comments: 24
_includes/item/audio-player.html (1)
  • 9-9: LGTM!
_includes/index/description.html (1)
  • 3-5: LGTM!
_includes/item/video-player.html (1)
  • 10-10: LGTM!
_layouts/data.html (1)
  • 18-18: LGTM!
_includes/item/image-gallery.html (1)
  • 8-9: LGTM!
_includes/item/citation-box.html (1)
  • 7-12: LGTM!
_includes/item/breadcrumbs.html (1)
  • 8-9: LGTM!
_includes/scroll-to-top.html (1)
  • 19-20: LGTM!
_layouts/home-infographic.html (1)
  • 6-23: LGTM!
_includes/feature/nav-menu.html (1)
  • 16-16: LGTM!
_includes/index/time.html (1)
  • 11-13: LGTM!
_includes/nav-search-lunr.html (1)
  • 9-12: LGTM!
_includes/js/table-js.html (1)
  • 8-21: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [2-18]

LGTM!

_layouts/search.html (1)
  • 5-21: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [8-41]

LGTM!

_includes/feature/audio.html (1)
  • 34-34: LGTM!
_includes/head/head.html (1)
  • 16-16: LGTM!
_includes/footer.html (1)
  • 28-39: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [31-48]

LGTM!

_layouts/browse.html (1)
  • 10-29: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [13-38]

LGTM!

_includes/head/page-meta.html (1)
  • 2-12: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [5-19]

LGTM!

_includes/head/item-meta.html (1)
  • 1-11: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [2-18]

LGTM!

_includes/js/lunr-js.html (1)
  • 3-7: LGTM!
_includes/index/data-download.html (1)
  • 4-25: LGTM!
_includes/item/download-buttons.html (1)
  • 14-15: LGTM!
docs/advanced_theme.md (1)
  • 36-42: LGTM!

@@ -35,7 +35,7 @@
<figure class="figure border rounded p-1 feature-w-{{ include.width | default: '100' }}">
<div class="{% unless include.height %}ratio ratio-{{ include.ratio | default: '1x1' }}{% endunless %}">
<object aria-label="pdf embed of {{ pdf_caption | escape }}" {% if include.height %}width="100%" height="{{ include.height }}"{% endif %} data="{{ src }}">
<p>The PDF is not rendering in your browser. Please <a href="{{ src }}">download the PDF</a> to view.</p>
<p>{{ site.data.translations['includesFeaturePdf']['pdfNotRendering'][site.lang] }} <a href="{{ src }}">{{ site.data.translations['includesFeaturePdf']['pdfDownload'][site.lang] }}</a>.</p>
Copy link

@coderabbitai coderabbitai bot Feb 5, 2024

Choose a reason for hiding this comment

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

Ensure the dynamic translation keys and site data access syntax are correctly implemented for internationalization best practices.

- {{ site.data.translations['includesFeaturePdf']['pdfNotRendering'][site.lang] }}
+ {{ site.data.translations.includesFeaturePdf.pdfNotRendering[site.lang] }}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<p>{{ site.data.translations['includesFeaturePdf']['pdfNotRendering'][site.lang] }} <a href="{{ src }}">{{ site.data.translations['includesFeaturePdf']['pdfDownload'][site.lang] }}</a>.</p>
<p>{{ site.data.translations.includesFeaturePdf.pdfNotRendering[site.lang] }} <a href="{{ src }}">{{ site.data.translations['includesFeaturePdf']['pdfDownload'][site.lang] }}</a>.</p>

Copy link
Member Author

Choose a reason for hiding this comment

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

Somehow this is not rendered correctly. Would I need to change _data/translations.yml as well?

Copy link

Choose a reason for hiding this comment

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

@maehr Based on the structure of your _data/translations.yml file, the original syntax you used (site.data.translations['includesFeaturePdf']['pdfNotRendering'][site.lang]) is correct for accessing the translations. The structure of your translations file uses nested keys, which necessitates the use of the bracket notation for keys that contain special characters or are variables (like site.lang in this case).

There's no need to change the _data/translations.yml file based on the output provided. The issue with rendering might be related to something else, such as the site.lang variable not being set or accessed correctly, or a potential typo elsewhere in your code that's affecting the rendering.

Ensure that site.lang is correctly defined and matches the keys (en, de, etc.) in your translations file. Also, double-check for any typos or syntax errors in the template or related configuration files that might affect the rendering of the translations.

If everything seems correct and the issue persists, consider reviewing how site.lang is set and ensuring it matches the expected values in your translations file.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Display the structure of the translations.yml file to understand the translation keys' structure.
cat _data/translations.yml

Length of output: 11386

Comment on lines +9 to +11
<a class="btn btn-secondary" href="{{ page.previous_item | relative_url }}" id="prev-page-button">&laquo; {{ site.data.translations['includesItemBrowseButtons']['previous'][site.lang] }}</a>
<a class="btn btn-secondary" href="{{ '/browse.html' | relative_url }}" >{{ site.data.translations['includesItemBrowseButtons']['backToBrowse'][site.lang] }}</a>
<a class="btn btn-secondary" href="{{ page.next_item | relative_url }}" id="next-page-button">{{ site.data.translations['includesItemBrowseButtons']['next'][site.lang] }} &raquo;</a>
Copy link

@coderabbitai coderabbitai bot Feb 5, 2024

Choose a reason for hiding this comment

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

Ensure the dynamic translation keys and site data access syntax are correctly implemented for internationalization best practices.

- {{ site.data.translations['includesItemBrowseButtons']['previous'][site.lang] }}
+ {{ site.data.translations.includesItemBrowseButtons.previous[site.lang] }}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<a class="btn btn-secondary" href="{{ page.previous_item | relative_url }}" id="prev-page-button">&laquo; {{ site.data.translations['includesItemBrowseButtons']['previous'][site.lang] }}</a>
<a class="btn btn-secondary" href="{{ '/browse.html' | relative_url }}" >{{ site.data.translations['includesItemBrowseButtons']['backToBrowse'][site.lang] }}</a>
<a class="btn btn-secondary" href="{{ page.next_item | relative_url }}" id="next-page-button">{{ site.data.translations['includesItemBrowseButtons']['next'][site.lang] }} &raquo;</a>
<a class="btn btn-secondary" href="{{ page.previous_item | relative_url }}" id="prev-page-button">&laquo; {{ site.data.translations.includesItemBrowseButtons.previous[site.lang] }}</a>
<a class="btn btn-secondary" href="{{ '/browse.html' | relative_url }}" >{{ site.data.translations['includesItemBrowseButtons']['backToBrowse'][site.lang] }}</a>
<a class="btn btn-secondary" href="{{ page.next_item | relative_url }}" id="next-page-button">{{ site.data.translations['includesItemBrowseButtons']['next'][site.lang] }} &raquo;</a>

Copy link
Member Author

Choose a reason for hiding this comment

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

Somehow this is not rendered correctly. Would I need to change _data/translations.yml as well?

Copy link

Choose a reason for hiding this comment

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

@maehr Based on the structure of your _data/translations.yml, it appears that the original syntax you used in the template ({{ site.data.translations['includesItemBrowseButtons']['previous'][site.lang] }}) is actually correct for accessing nested keys in your translations file. The structure of your translations file uses nested keys, which means the bracket notation is necessary for accessing keys that contain special characters or are variables (like site.lang in this case).

If the translations are not rendering correctly, the issue might not be with the syntax used for accessing the translation keys but could be related to other factors such as:

  • The site.lang variable not being set or not matching the keys (en, de, etc.) in your translations file.
  • A typo or inconsistency in the key names within the translations file or the template.

You do not need to change the structure of _data/translations.yml based on the output provided. It's structured correctly for the type of dynamic translation you're implementing. Ensure that the site.lang variable is correctly set and matches the language codes in your translations file. Also, double-check for any typos in the key names both in your template and the translations file.

If everything seems correct and the issue persists, consider reviewing how and where the site.lang variable is set and ensuring it matches the expected values (en, de, etc.) in your translations file.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Display the structure of the translations.yml file to understand how translation keys are organized.
cat _data/translations.yml

Length of output: 11386

Comment on lines +13 to +25
<a class="text-dark" href="{{ 'image' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['images'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-image"/></svg></a><br>
{% when 'audio' %}
<a class="text-dark" href="{{ 'audio' | prepend: '/browse.html#' | relative_url }}">Audio File{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-audio"/></svg></a><br>
<a class="text-dark" href="{{ 'audio' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['audio'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-audio"/></svg></a><br>
{% when 'video' %}
<a class="text-dark" href="{{ 'video' | prepend: '/browse.html#' | relative_url }}">Video{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-video"/></svg></a><br>
<a class="text-dark" href="{{ 'video' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['videos'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-video"/></svg></a><br>
{% when 'pdf' %}
<a class="text-dark" href="{{ 'pdf' | prepend: '/browse.html#' | relative_url }}">PDF{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-pdf"/></svg></a><br>
{% when 'panorama' %}
<a class="text-dark" href="{{ 'panorama' | prepend: '/browse.html#' | relative_url }}">Panorama{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-panorama"/></svg></a><br>
<a class="text-dark" href="{{ 'pdf' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['pdfs'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-pdf"/></svg></a><br>
{% when 'record' %}
<a class="text-dark" href="{{ 'record' | prepend: '/browse.html#' | relative_url }}">Record{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-record"/></svg></a><br>
<a class="text-dark" href="{{ 'record' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['records'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-record"/></svg></a><br>
{% when 'compound_object' %}
<a class="text-dark" href="{{ 'compound%20object' | prepend: '/browse.html#' | relative_url }}">Compound Object{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-compound-object"/></svg></a><br>
<a class="text-dark" href="{{ 'compound%20object' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['compoundObjects'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-compound-object"/></svg></a><br>
{% when 'multiple' %}
<a class="text-dark" href="{{ 'multiple' | prepend: '/browse.html#' | relative_url }}">Multiple{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-multiple"/></svg></a><br>
<a class="text-dark" href="{{ 'multiple' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['multiples'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-multiple"/></svg></a><br>
Copy link

@coderabbitai coderabbitai bot Feb 5, 2024

Choose a reason for hiding this comment

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

Ensure the dynamic translation keys and site data access syntax are correctly implemented for internationalization best practices.

- {{ site.data.translations['includesIndexObjects']['images'][site.lang] }}
+ {{ site.data.translations.includesIndexObjects.images[site.lang] }}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<a class="text-dark" href="{{ 'image' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['images'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-image"/></svg></a><br>
{% when 'audio' %}
<a class="text-dark" href="{{ 'audio' | prepend: '/browse.html#' | relative_url }}">Audio File{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-audio"/></svg></a><br>
<a class="text-dark" href="{{ 'audio' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['audio'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-audio"/></svg></a><br>
{% when 'video' %}
<a class="text-dark" href="{{ 'video' | prepend: '/browse.html#' | relative_url }}">Video{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-video"/></svg></a><br>
<a class="text-dark" href="{{ 'video' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['videos'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-video"/></svg></a><br>
{% when 'pdf' %}
<a class="text-dark" href="{{ 'pdf' | prepend: '/browse.html#' | relative_url }}">PDF{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-pdf"/></svg></a><br>
{% when 'panorama' %}
<a class="text-dark" href="{{ 'panorama' | prepend: '/browse.html#' | relative_url }}">Panorama{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-panorama"/></svg></a><br>
<a class="text-dark" href="{{ 'pdf' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['pdfs'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-pdf"/></svg></a><br>
{% when 'record' %}
<a class="text-dark" href="{{ 'record' | prepend: '/browse.html#' | relative_url }}">Record{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-record"/></svg></a><br>
<a class="text-dark" href="{{ 'record' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['records'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-record"/></svg></a><br>
{% when 'compound_object' %}
<a class="text-dark" href="{{ 'compound%20object' | prepend: '/browse.html#' | relative_url }}">Compound Object{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-compound-object"/></svg></a><br>
<a class="text-dark" href="{{ 'compound%20object' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['compoundObjects'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-compound-object"/></svg></a><br>
{% when 'multiple' %}
<a class="text-dark" href="{{ 'multiple' | prepend: '/browse.html#' | relative_url }}">Multiple{% if count > 1 %}s{% endif %} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-multiple"/></svg></a><br>
<a class="text-dark" href="{{ 'multiple' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['multiples'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-multiple"/></svg></a><br>
<a class="text-dark" href="{{ 'image' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations.includesIndexObjects.images[site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-image"/></svg></a><br>
{% when 'audio' %}
<a class="text-dark" href="{{ 'audio' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['audio'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-audio"/></svg></a><br>
{% when 'video' %}
<a class="text-dark" href="{{ 'video' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['videos'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-video"/></svg></a><br>
{% when 'pdf' %}
<a class="text-dark" href="{{ 'pdf' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['pdfs'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-pdf"/></svg></a><br>
{% when 'record' %}
<a class="text-dark" href="{{ 'record' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['records'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-record"/></svg></a><br>
{% when 'compound_object' %}
<a class="text-dark" href="{{ 'compound%20object' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['compoundObjects'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-compound-object"/></svg></a><br>
{% when 'multiple' %}
<a class="text-dark" href="{{ 'multiple' | prepend: '/browse.html#' | relative_url }}">{{ site.data.translations['includesIndexObjects']['multiples'][site.lang] }} <svg class="bi icon-sprite text-body" fill="currentColor" aria-hidden="true"><use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#icon-multiple"/></svg></a><br>

Copy link
Member Author

Choose a reason for hiding this comment

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

Somehow this is not rendered correctly. Would I need to change _data/translations.yml as well?

Copy link

Choose a reason for hiding this comment

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

@maehr Based on the content of _data/translations.yml, the file is correctly structured to support the dot notation access method as suggested. The translations for includesIndexObjects are properly nested and labeled, matching the keys used in the suggestion. Therefore, the issue with rendering might not be directly related to the structure of the YAML file.

If the rendering issue persists, ensure that:

  1. The site.lang variable is correctly set and matches one of the language codes (en, de, etc.) in the translations file.
  2. There are no typos in the YAML file keys or in the template where the translations are being accessed.
  3. The Jekyll site is being rebuilt after making changes to the _data/translations.yml or any template files to reflect the updates.

If all the above are correct and the issue still occurs, it might be helpful to review the Jekyll build logs for any errors or warnings related to the translations or data files.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Display the content of `_data/translations.yml` to understand its structure and verify compatibility with the suggested syntax change.
cat _data/translations.yml

Length of output: 11386

@@ -49,7 +49,7 @@
{% else %}
<video width="320" height="240" controls>
<source src="{{ video_src }}">
Your browser does not support the video tag.
{{ site.data.translations['includesFeatureVideo']['videoNotSupported'][site.lang] }}
Copy link

@coderabbitai coderabbitai bot Feb 5, 2024

Choose a reason for hiding this comment

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

Ensure the dynamic translation keys and site data access syntax are correctly implemented for internationalization best practices.

- {{ site.data.translations['includesFeatureVideo']['videoNotSupported'][site.lang] }}
+ {{ site.data.translations.includesFeatureVideo.videoNotSupported[site.lang] }}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
{{ site.data.translations['includesFeatureVideo']['videoNotSupported'][site.lang] }}
{{ site.data.translations.includesFeatureVideo.videoNotSupported[site.lang] }}

Copy link
Member Author

Choose a reason for hiding this comment

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

Somehow this is not rendered correctly. Would I need to change _data/translations.yml as well?

Copy link

Choose a reason for hiding this comment

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

@maehr Based on the output from _data/translations.yml, the structure of your translations file seems correct for accessing the videoNotSupported translations using either dot notation or the ['key'] syntax. The issue with rendering might not be due to the syntax used in the template but could be related to other factors such as the site.lang variable not being correctly set or matched.

Given the structure:

includesFeatureVideo:
  videoNotSupported:
    en: "Your browser does not support the embedded video."
    de: "Ihr Browser unterstützt das eingebettete Video nicht."

Both of the following syntaxes should correctly access the translation strings:

{{ site.data.translations['includesFeatureVideo']['videoNotSupported'][site.lang] }}
{{ site.data.translations.includesFeatureVideo.videoNotSupported[site.lang] }}

If the translation is not rendering correctly, please ensure that:

  1. The site.lang variable is correctly set in your site's configuration and matches one of the keys (en, de, etc.) in your translations.
  2. There are no typos in the variable names or in the path used to access the translation in your template.

If everything seems correct and you're still facing issues, it might be helpful to review the site's configuration for language settings or consider if any other part of your Jekyll setup could be affecting the rendering of translations.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Display the structure of the translations.yml file, focusing on the includesFeatureVideo.videoNotSupported section.
cat _data/translations.yml | grep -A 10 "includesFeatureVideo:"

Length of output: 359

@@ -24,7 +24,7 @@
{%- if navYears -%}
<div class="dropdown float-end" id="year-nav">
<button class="btn btn-primary dropdown-toggle" type="button" id="yearButton" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Year
{{ site.data.translations['layoutsTimeline']['year'][site.lang] }}
Copy link

@coderabbitai coderabbitai bot Feb 5, 2024

Choose a reason for hiding this comment

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

Ensure the dynamic translation keys and site data access syntax are correctly implemented for internationalization best practices.

- {{ site.data.translations['layoutsTimeline']['year'][site.lang] }}
+ {{ site.data.translations.layoutsTimeline.year[site.lang] }}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
{{ site.data.translations['layoutsTimeline']['year'][site.lang] }}
{{ site.data.translations.layoutsTimeline.year[site.lang] }}

Copy link
Member Author

Choose a reason for hiding this comment

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

Somehow this is not rendered correctly. Would I need to change _data/translations.yml as well?

Copy link

Choose a reason for hiding this comment

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

@maehr Based on the structure of _data/translations.yml, it appears that the original syntax you used ({{ site.data.translations['layoutsTimeline']['year'][site.lang] }}) is correct and should work as intended, given that the structure of the YAML file uses nested keys. The issue with rendering might not be related to the syntax used for accessing the translation keys.

Since the YAML structure confirms that the keys are nested under layoutsTimeline and then year, with language codes en and de as further nested keys, the original access pattern is appropriate for this structure. There's no need to change _data/translations.yml based on the provided output.

If the translation is not rendering correctly, ensure that:

  1. The site.lang variable is correctly set to either en or de.
  2. There are no typos in the language codes or in the path used to access the translation in the template.

If everything seems correct but the issue persists, it might be helpful to review the Jekyll build logs for any warnings or errors related to data file processing or template rendering that could provide further clues.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Check the structure of `_data/translations.yml`
cat _data/translations.yml

Length of output: 11386

Comment on lines +50 to +54
<span class="visually-hidden">{{ site.data.translations['includesIndexCarousel']['prev'][site.lang] }}</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#imageCarousel" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
<span class="visually-hidden">{{ site.data.translations['includesIndexCarousel']['next'][site.lang] }}</span>
Copy link

@coderabbitai coderabbitai bot Feb 5, 2024

Choose a reason for hiding this comment

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

Ensure the dynamic translation keys and site data access syntax are correctly implemented for internationalization best practices.

- {{ site.data.translations['includesIndexCarousel']['prev'][site.lang] }}
+ {{ site.data.translations.includesIndexCarousel.prev[site.lang] }}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<span class="visually-hidden">{{ site.data.translations['includesIndexCarousel']['prev'][site.lang] }}</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#imageCarousel" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
<span class="visually-hidden">{{ site.data.translations['includesIndexCarousel']['next'][site.lang] }}</span>
<span class="visually-hidden">{{ site.data.translations.includesIndexCarousel.prev[site.lang] }}</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#imageCarousel" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">{{ site.data.translations['includesIndexCarousel']['next'][site.lang] }}</span>

Copy link
Member Author

Choose a reason for hiding this comment

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

Somehow this is not rendered correctly. Would I need to change _data/translations.yml as well?

Copy link

Choose a reason for hiding this comment

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

@maehr Based on the structure of the _data/translations.yml file, it appears that the correct key for accessing the "Previous" and "Next" translations under includesIndexCarousel should indeed be previous and next rather than prev and next as initially suggested. The file uses previous instead of prev, which likely caused the rendering issue. No changes to _data/translations.yml are necessary in terms of key names, but the access method in the template should be updated to match the correct keys as follows:

- {{ site.data.translations['includesIndexCarousel']['prev'][site.lang] }}
+ {{ site.data.translations.includesIndexCarousel.previous[site.lang] }}

And for the "Next" button, the current implementation is correct:

{{ site.data.translations.includesIndexCarousel.next[site.lang] }}

Please update the access method for the "Previous" button in your template to match the correct key as shown above. This should resolve the rendering issue.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Display the structure of the translations.yml file to understand how translations are organized.
cat _data/translations.yml

Length of output: 11386

Comment on lines 4 to 15
{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid and item.parentid == nil' -%}
{% endif %}
{%- assign fields = site.data.config-browse -%}
{%- assign viewFullRecord = site.data.translations['includesJsBrowseJs']['viewFullRecord'][site.lang] -%}

<script>

var viewFullRecord = {{ viewFullRecord | jsonify}};

/* add items */
var items = [
{% for item in items %}
Copy link

@coderabbitai coderabbitai bot Feb 5, 2024

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [7-83]

Ensure the JavaScript syntax for defining and using dynamic translations is correctly implemented. Verify the use of jsonify for the translation variable and its usage in HTML generation.

- var viewFullRecord = {{ viewFullRecord | jsonify}};
+ var viewFullRecord = "{{ viewFullRecord }}";

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a liquid tag, not JS.

Copy link

Choose a reason for hiding this comment

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

@maehr, thank you for clarifying the use of the Liquid tag within the JavaScript context. You're absolutely right; the {{ viewFullRecord | jsonify }} syntax is appropriate for embedding JSON-formatted strings from Liquid into JavaScript. My previous suggestion overlooked the specific interplay between Liquid and JavaScript in this context. I appreciate your patience and the correction.

Comment on lines +9 to +83
<button type="button" class="btn btn-primary btn-lg float-md-end" data-bs-toggle="modal" data-bs-target="#dataModal">{{ site.data.translations['includesCollectionBanner']['downloadButton'][site.lang] }}</button>
<!-- Modal -->
<div class="modal fade" id="dataModal" tabindex="-1" role="dialog" aria-labelledby="dataModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="dataModalLabel">Collection Data</h1>
<h1 class="modal-title" id="dataModalLabel">{{ site.data.translations['includesCollectionBanner']['title'][site.lang] }}</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">

<p>Download this collection's data in a variety of reusable formats.</p>
<p>{{ site.data.translations['includesCollectionBanner']['description'][site.lang] }}</p>

{% if site.data.theme.metadata-export-fields %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">Complete Metadata</h2>
<p class="card-text">All metadata fields for all collection items, available as a CSV spreadsheet (usable in Excel, Google Sheets, and similar programs) or JSON file (often used with web applications).</p>
<a href="{{ '/assets/data/metadata.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">Metadata CSV</a>
<a href="{{ '/assets/data/metadata.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">Metadata JSON</a>
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['completeMetadata'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['completeMetadataDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/metadata.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['metadata'][site.lang] }} CSV</a>
<a href="{{ '/assets/data/metadata.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['metadata'][site.lang] }} JSON</a>
</div>
</div>
{%- endif -%}
{% if site.data.theme.metadata-facets-fields %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">Metadata Facets</h2>
<p class="card-text">List of unique values and their count for specific metadata fields, useful for understanding content of the fields.</p>
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['metadataFacets'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['metadataFacetsDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/facets.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">Facets JSON</a>
</div>
</div>
{%- endif -%}
{% if stubs contains "subject" %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">Subject Metadata</h2>
<p class="card-text">Unique values and counts of subject metadata, useful for further analyzing the content of this collection.</p>
<a href="{{ '/assets/data/subjects.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">Subjects CSV</a>
<a href="{{ '/assets/data/subjects.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">Subjects JSON</a>
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['subjectMetadata'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['subjectMetadataDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/subjects.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['subjects'][site.lang] }} CSV</a>
<a href="{{ '/assets/data/subjects.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['subjects'][site.lang] }} JSON</a>
</div>
</div>
{% endif %}
{% if stubs contains "location" %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">Locations</h2>
<p class="card-text">Unique values and counts of location metadata, useful for further visualization and analysis of this collection's place names.</p>
<a href="{{ '/assets/data/locations.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">Locations CSV</a>
<a href="{{ '/assets/data/locations.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">Locations JSON</a>
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['locations'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['locationsDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/locations.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['locations'][site.lang] }} CSV</a>
<a href="{{ '/assets/data/locations.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['locations'][site.lang] }} JSON</a>
</div>
</div>
{%- endif -%}
{% if stubs contains "map" %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">GeoJSON</h2>
<p class="card-text">Metadata for all collection items that have geographic coordinates in <a href="https://en.wikipedia.org/wiki/GeoJSON" target="_blank" rel="noopener">GeoJSON</a> format, useful for further exploration and analysis of this collection through a geographical lense.</p>
<a href="{{ '/assets/data/geodata.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">Geodata JSON</a>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['geodataDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/geodata.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['geodata'][site.lang] }} JSON</a>
</div>
</div>
{%- endif -%}
{% if stubs contains "timeline" %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">Timeline</h2>
<p class="card-text">A time-focused JSON data export designed for use with <a href="https://timeline.knightlab.com/" target="_blank" rel="noopener">TimelineJS</a>.</p>
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['timeline'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['timelineDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/timelinejs.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">TimelineJS JSON</a>
</div>
</div>
{%- endif -%}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">Website Source Code</h2>
<p class="card-text">GitHub repository containing source code for this project built with <a href="https://github.com/CollectionBuilder/collectionbuilder-csv" target="_blank" rel="noopener">CollectionBuilder-CSV</a>.</p>
<a href="{{ site.source-code | default: 'https://github.com/CollectionBuilder/collectionbuilder-csv' }}" class="btn btn-outline-dark" target="_blank" rel="noopener">Source Code</a>
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['websiteSourceCode'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['websiteSourceCodeDescription'][site.lang] }}</p>
<a href="{{ site.source-code | default: 'https://github.com/CollectionBuilder/collectionbuilder-csv' }}" class="btn btn-outline-dark" target="_blank" rel="noopener">{{ site.data.translations['includesCollectionBanner']['sourceCode'][site.lang] }}</a>
Copy link

@coderabbitai coderabbitai bot Feb 5, 2024

Choose a reason for hiding this comment

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

Ensure the dynamic translation keys and site data access syntax are correctly implemented for internationalization best practices across all modal content.

- {{ site.data.translations['includesCollectionBanner']['downloadButton'][site.lang] }}
+ {{ site.data.translations.includesCollectionBanner.downloadButton[site.lang] }}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<button type="button" class="btn btn-primary btn-lg float-md-end" data-bs-toggle="modal" data-bs-target="#dataModal">{{ site.data.translations['includesCollectionBanner']['downloadButton'][site.lang] }}</button>
<!-- Modal -->
<div class="modal fade" id="dataModal" tabindex="-1" role="dialog" aria-labelledby="dataModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="dataModalLabel">Collection Data</h1>
<h1 class="modal-title" id="dataModalLabel">{{ site.data.translations['includesCollectionBanner']['title'][site.lang] }}</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Download this collection's data in a variety of reusable formats.</p>
<p>{{ site.data.translations['includesCollectionBanner']['description'][site.lang] }}</p>
{% if site.data.theme.metadata-export-fields %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">Complete Metadata</h2>
<p class="card-text">All metadata fields for all collection items, available as a CSV spreadsheet (usable in Excel, Google Sheets, and similar programs) or JSON file (often used with web applications).</p>
<a href="{{ '/assets/data/metadata.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">Metadata CSV</a>
<a href="{{ '/assets/data/metadata.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">Metadata JSON</a>
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['completeMetadata'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['completeMetadataDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/metadata.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['metadata'][site.lang] }} CSV</a>
<a href="{{ '/assets/data/metadata.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['metadata'][site.lang] }} JSON</a>
</div>
</div>
{%- endif -%}
{% if site.data.theme.metadata-facets-fields %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">Metadata Facets</h2>
<p class="card-text">List of unique values and their count for specific metadata fields, useful for understanding content of the fields.</p>
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['metadataFacets'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['metadataFacetsDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/facets.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">Facets JSON</a>
</div>
</div>
{%- endif -%}
{% if stubs contains "subject" %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">Subject Metadata</h2>
<p class="card-text">Unique values and counts of subject metadata, useful for further analyzing the content of this collection.</p>
<a href="{{ '/assets/data/subjects.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">Subjects CSV</a>
<a href="{{ '/assets/data/subjects.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">Subjects JSON</a>
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['subjectMetadata'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['subjectMetadataDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/subjects.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['subjects'][site.lang] }} CSV</a>
<a href="{{ '/assets/data/subjects.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['subjects'][site.lang] }} JSON</a>
</div>
</div>
{% endif %}
{% if stubs contains "location" %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">Locations</h2>
<p class="card-text">Unique values and counts of location metadata, useful for further visualization and analysis of this collection's place names.</p>
<a href="{{ '/assets/data/locations.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">Locations CSV</a>
<a href="{{ '/assets/data/locations.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">Locations JSON</a>
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['locations'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['locationsDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/locations.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['locations'][site.lang] }} CSV</a>
<a href="{{ '/assets/data/locations.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['locations'][site.lang] }} JSON</a>
</div>
</div>
{%- endif -%}
{% if stubs contains "map" %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">GeoJSON</h2>
<p class="card-text">Metadata for all collection items that have geographic coordinates in <a href="https://en.wikipedia.org/wiki/GeoJSON" target="_blank" rel="noopener">GeoJSON</a> format, useful for further exploration and analysis of this collection through a geographical lense.</p>
<a href="{{ '/assets/data/geodata.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">Geodata JSON</a>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['geodataDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/geodata.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['geodata'][site.lang] }} JSON</a>
</div>
</div>
{%- endif -%}
{% if stubs contains "timeline" %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">Timeline</h2>
<p class="card-text">A time-focused JSON data export designed for use with <a href="https://timeline.knightlab.com/" target="_blank" rel="noopener">TimelineJS</a>.</p>
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['timeline'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['timelineDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/timelinejs.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">TimelineJS JSON</a>
</div>
</div>
{%- endif -%}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">Website Source Code</h2>
<p class="card-text">GitHub repository containing source code for this project built with <a href="https://github.com/CollectionBuilder/collectionbuilder-csv" target="_blank" rel="noopener">CollectionBuilder-CSV</a>.</p>
<a href="{{ site.source-code | default: 'https://github.com/CollectionBuilder/collectionbuilder-csv' }}" class="btn btn-outline-dark" target="_blank" rel="noopener">Source Code</a>
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['websiteSourceCode'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['websiteSourceCodeDescription'][site.lang] }}</p>
<a href="{{ site.source-code | default: 'https://github.com/CollectionBuilder/collectionbuilder-csv' }}" class="btn btn-outline-dark" target="_blank" rel="noopener">{{ site.data.translations['includesCollectionBanner']['sourceCode'][site.lang] }}</a>
<button type="button" class="btn btn-primary btn-lg float-md-end" data-bs-toggle="modal" data-bs-target="#dataModal">{{ site.data.translations.includesCollectionBanner.downloadButton[site.lang] }}</button>
<!-- Modal -->
<div class="modal fade" id="dataModal" tabindex="-1" role="dialog" aria-labelledby="dataModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="dataModalLabel">{{ site.data.translations['includesCollectionBanner']['title'][site.lang] }}</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>{{ site.data.translations['includesCollectionBanner']['description'][site.lang] }}</p>
{% if site.data.theme.metadata-export-fields %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['completeMetadata'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['completeMetadataDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/metadata.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['metadata'][site.lang] }} CSV</a>
<a href="{{ '/assets/data/metadata.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['metadata'][site.lang] }} JSON</a>
</div>
</div>
{%- endif -%}
{% if site.data.theme.metadata-facets-fields %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['metadataFacets'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['metadataFacetsDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/facets.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">Facets JSON</a>
</div>
</div>
{%- endif -%}
{% if stubs contains "subject" %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['subjectMetadata'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['subjectMetadataDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/subjects.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['subjects'][site.lang] }} CSV</a>
<a href="{{ '/assets/data/subjects.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['subjects'][site.lang] }} JSON</a>
</div>
</div>
{% endif %}
{% if stubs contains "location" %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['locations'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['locationsDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/locations.csv' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['locations'][site.lang] }} CSV</a>
<a href="{{ '/assets/data/locations.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['locations'][site.lang] }} JSON</a>
</div>
</div>
{%- endif -%}
{% if stubs contains "map" %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">GeoJSON</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['geodataDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/geodata.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">{{ site.data.translations['includesCollectionBanner']['geodata'][site.lang] }} JSON</a>
</div>
</div>
{%- endif -%}
{% if stubs contains "timeline" %}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['timeline'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['timelineDescription'][site.lang] }}</p>
<a href="{{ '/assets/data/timelinejs.json' | relative_url }}" class="btn btn-outline-dark" target="_blank">TimelineJS JSON</a>
</div>
</div>
{%- endif -%}
<div class="card my-3">
<div class="card-body">
<h2 class="card-title h4">{{ site.data.translations['includesCollectionBanner']['websiteSourceCode'][site.lang] }}</h2>
<p class="card-text">{{ site.data.translations['includesCollectionBanner']['websiteSourceCodeDescription'][site.lang] }}</p>
<a href="{{ site.source-code | default: 'https://github.com/CollectionBuilder/collectionbuilder-csv' }}" class="btn btn-outline-dark" target="_blank" rel="noopener">{{ site.data.translations['includesCollectionBanner']['sourceCode'][site.lang] }}</a>

Copy link
Member Author

Choose a reason for hiding this comment

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

Somehow this is not rendered correctly. Would I need to change _data/translations.yml as well?

Copy link

Choose a reason for hiding this comment

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

@maehr Based on the structure of the _data/translations.yml file, it appears that the original notation using brackets and quotes is correct for accessing nested translation keys. The dot notation suggested in the previous comment might not work as expected due to the specific way keys are named and structured in the YAML file. The keys include characters like - which cannot be navigated using dot notation in Liquid templates. Therefore, no changes to the _data/translations.yml file are necessary for this aspect. The correct way to access the translations, given the YAML structure, is indeed with the bracket and string notation as you have initially used.

For example, to access the download button text in the correct language, you should use:

{{ site.data.translations['includesCollectionBanner']['downloadButton'][site.lang] }}

This approach is consistent with the YAML structure and Liquid template syntax for accessing nested dictionary elements, especially when keys contain characters like -.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Display the structure of the translations.yml file to understand how translation keys are structured.
cat _data/translations.yml

Length of output: 11386

@maehr maehr closed this Feb 8, 2024
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.

1 participant