Skip to content

Commit

Permalink
Feature: Make the word "Ontology" configurable in all the portal (#520)
Browse files Browse the repository at this point in the history
* update the fr.file

* remove the duplicated keys in en.yml file

* internationalization of ontologies helpers

* fix the bug of missing translate error

* Internationalization of remaining files

* remove duplicated keys and update the en.yml file

* remove duplicated keys and update the fr.yml file

* add the logic to replace ontology with semantic term

* fix the bug of missing translation

* fix the bug of missing translation

* add the semantic term in it and de files

* resolve the problem of translation terms

* include ApplicationHelper into components.rb to use t(*args) function

* add vocabulary, terminology and semantic_artefact terms in all languages

* add Resource term to config file

* add InternationalisationHelper

* Remove the logic of configuring the ontology from the ApplicationHelper

* include the InternationalisationHelper into the components.rb

* fix the bug of syntax error

* eliminate the use of the words ontology and semantic resource together

* remove unused code

* add documentation to the function

* add resource term variable to bioportal config

* add comment in all languages to explain how to use the  resource term

* handle the case of the $RESOURCE_TERM  variable is not set

---------

Co-authored-by: Syphax bouazzouni <[email protected]>
  • Loading branch information
SirineMhedhbi and syphax-bouazzouni committed Mar 25, 2024
1 parent 9962096 commit 94c067e
Show file tree
Hide file tree
Showing 18 changed files with 192 additions and 40 deletions.
7 changes: 4 additions & 3 deletions app/components/display/search_result_component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Display::SearchResultComponent < ViewComponent::Base
include ModalHelper

renders_many :subresults, Display::SearchResultComponent
renders_many :reuses, Display::SearchResultComponent
def initialize(number: 0,title: nil, ontology_acronym: nil ,uri: nil, definition: nil, link: nil, is_sub_component: false)
Expand All @@ -16,11 +17,11 @@ def sub_component_class
@is_sub_component ? 'sub-component' : ''
end

def sub_ontologies_id
def sub_ontologies_id
string = @number+'_sub_ontologies'
end

def reuses_id
def reuses_id
string = @number+'_reuses'
end

Expand Down Expand Up @@ -51,4 +52,4 @@ def reveal_ontologies_button(text,id,icon)
inline_svg_tag("icons/arrow-down.svg")
end
end
end
end
2 changes: 1 addition & 1 deletion app/components/input/language_selector_component.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Input::LanguageSelectorComponent < ViewComponent::Base

include InternationalisationHelper
def initialize(languages:, selected: nil, id: '', name: '' , enable_all: false, **html_options)
super
@languages = languages
Expand Down
3 changes: 2 additions & 1 deletion app/components/link_text_component.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class LinkTextComponent < ViewComponent::Base
include InternationalisationHelper

def initialize(text:, icon: nil, target: nil)
@text = text
Expand All @@ -12,5 +13,5 @@ def call
svg_icon = !@icon&.empty? ? inline_svg(@icon) : ''
extra_span = @text == t('mappings.upload_mappings') ? '' : "<span class='mx-1'>#{svg_icon}</span>"
"#{@text}#{extra_span}".html_safe
end
end
end
1 change: 1 addition & 0 deletions app/components/loader_component.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class LoaderComponent < ViewComponent::Base
include ApplicationHelper
include ActionView::Helpers::TagHelper

def initialize(small: false, type: nil)
Expand Down
1 change: 1 addition & 0 deletions app/components/ontology_search_input_component.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class OntologySearchInputComponent < ViewComponent::Base
include InternationalisationHelper

def initialize(name: 'search', placeholder: t('ontologies.ontology_search_prompt'), scroll_down: true, search_icon_type: nil)
@name = name
Expand Down
3 changes: 2 additions & 1 deletion app/components/ontology_subscribe_button_component.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class OntologySubscribeButtonComponent < ViewComponent::Base
include ApplicationHelper
def initialize(id: '', ontology_id:, subscribed:, user_id:, count: 0, link: 'javascript:void(0);')
super
@id = id
Expand All @@ -19,7 +20,7 @@ def initialize(id: '', ontology_id:, subscribed:, user_id:, count: 0, link: 'jav
title: title
}
end

def title
if @subscribed
t('components.resource', sub_text: @sub_text)
Expand Down
3 changes: 2 additions & 1 deletion app/components/text_area_field_component.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class TextAreaFieldComponent < ViewComponent::Base
include InternationalisationHelper

def initialize(value: , see_more_text: t('components.see_more') , see_less_text: t('components.see_less'))
super
Expand All @@ -9,4 +10,4 @@ def initialize(value: , see_more_text: t('components.see_more') , see_less_text:
@see_less_text = see_less_text
end

end
end
3 changes: 2 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base

include InternationalisationHelper

before_action :set_locale

# Sets the locale based on the locale cookie or the value returned by detect_locale.
Expand Down
1 change: 1 addition & 0 deletions app/controllers/recommender_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class RecommenderController < ApplicationController
layout :determine_layout
include ApplicationHelper
include InternationalisationHelper
# REST_URI is defined in application_controller.rb
RECOMMENDER_URI = "/recommender"

Expand Down
1 change: 0 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -629,5 +629,4 @@ def cancel_button_component(class_name: nil, id: , value:, data: nil)
end
end
end

end
31 changes: 31 additions & 0 deletions app/helpers/internationalisation_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module InternationalisationHelper

#Implement logic to make the term 'ontology' configurable throughout the portal, allowing it to be replaced with the variable $RESOURCE_TERM
def t(*args)
translation = I18n.t(*args).downcase
term = I18n.t("resource_term.ontology")
plural_term = I18n.t("resource_term.ontology_plural")
single_term = I18n.t("resource_term.ontology_single")
resource = I18n.t("resource_term.#{$RESOURCE_TERM}")
resources = I18n.t("resource_term.#{$RESOURCE_TERM}_plural")
a_resource = I18n.t("resource_term.#{$RESOURCE_TERM}_single")

if translation.include?(term) && resource
replacement = resource.capitalize
replacement = resource if translation.include?(term)
if translation.include?(single_term)
term = single_term
replacement = a_resource
end
translation.gsub(term, replacement)

elsif translation.include?(plural_term) && resources
replacement = resources.capitalize
replacement = resources if translation.include?(plural_term)
translation.gsub(plural_term, replacement)
else
I18n.t(*args)
end
end

end
2 changes: 1 addition & 1 deletion app/views/home/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
.home-header-title-container
.home-header-title
%h4
= t('.welcome', site: $SITE)
= t('home.index.welcome', site: $SITE)
%p
= t('home.index.tagline')
= render OntologySearchInputComponent.new(search_icon_type: 'home')
Expand Down
3 changes: 3 additions & 0 deletions config/bioportal_config_env.rb.sample
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,6 @@ $CITE_ANNOTATOR = 'https://hal.science/hal-00492024'
$ANNOTATOR_API_DOC = 'https://data.agroportal.lirmm.fr/documentation#nav_annotator'

$CITE_RECOMMENDER = 'https://doi.org/10.1186/s13326-017-0128-y'

# Resource term
$RESOURCE_TERM = ENV['RESOURCE_TERM'] || 'ontology'
5 changes: 5 additions & 0 deletions config/bioportal_config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
$ANNOTATOR_URL = $PROXY_URL = ENV['ANNOTATOR_URL']
$FAIRNESS_URL = ENV['FAIRNESS_URL']

# Resource term
$RESOURCE_TERM = ENV['RESOURCE_TERM']

# config/initializers/omniauth_providers.rb
$OMNIAUTH_PROVIDERS = {
github: {
Expand Down Expand Up @@ -219,3 +222,5 @@
if File.exist?('config/bioportal_config_development_testportal.lirmm.fr.rb')
require_relative 'bioportal_config_development_testportal.lirmm.fr' # local credentials
end

$RESOURCE_TERM = ENV['RESOURCE_TERM'] || 'ontology'
24 changes: 22 additions & 2 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@ de:
invalid_license_key: is an invalid license key
no_appliance_id_for_comparison: Could not be validated. Unable to retrieve virtual appliance ID.
appliance_id_mismatch: is an appliance id mismatch
# Konfigurieren Sie den Ressourcenbegriff 'ontology' im gesamten Portal so, dass er durch alternative Begriffe wie 'semantic_resource', 'vocabulary', 'terminology' oder 'semantic_artefact' ersetzt werden kann.
resource_term:
ontology: Ontologie
ontology_plural: Ontologien
ontology_single: eine Ontologie

semantic_resource: semantische Ressource
semantic_resource_plural: semantische Ressourcen
semantic_resource_single: eine semantische Ressource

vocabulary: Vokabular
vocabulary_plural: Vokabulare
vocabulary_single: ein Vokabular

terminology: Terminologie
terminology_plural: Terminologien
terminology_single: eine Terminologie

semantic_artefact: semantisches Artefakt
semantic_artefact_plural: semantische Artefakte
semantic_artefact_single: ein semantisches Artefakt

date:
formats:
Expand Down Expand Up @@ -140,8 +161,7 @@ de:
und befürworten
group: Gruppe
groups_and_categories: Gruppen und Kategorien
intro: Visualisierung von Daten, die aus im Portal gespeicherten Ontologien abgerufen
werden
intro: Visualisieren Sie das Panorama aller Ontologien auf %{site} durch die Aggregation von Metadaten.
more_properties_charts: Weitere Eigenschaftsdiagramme
most_active_ontologies: Die aktivsten Ontologien
most_active_organizations: Die aktivsten Organisationen
Expand Down
48 changes: 35 additions & 13 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,28 @@ en:
invalid_license_key: is an invalid license key.
no_appliance_id_for_comparison: Could not be validated. Unable to retrieve virtual appliance ID.
appliance_id_mismatch: is an appliance id mismatch.

# Make the resource_term 'ontology' configurable throughout the portal, allowing it to be replaced by alternative terms such as 'semantic_resource', 'vocabulary', 'terminology', or 'semantic_artefact'
resource_term:
ontology: ontology
ontology_plural: ontologies
ontology_single: an ontology

semantic_resource: semantic resource
semantic_resource_plural: semantic resources
semantic_resource_single: a semantic resource

vocabulary: vocabulary
vocabulary_plural: vocabularies
vocabulary_single: a vocabulary

terminology: terminology
terminology_plural: terminologies
terminology_single: a terminology

semantic_artefact: semantic artefact
semantic_artefact_plural: semantic artefacts
semantic_artefact_single: a semantic artefact

date:
formats:
Expand Down Expand Up @@ -419,7 +440,7 @@ en:
funding_endorsing_organizations: Organizations funding and endorsing the most ontologies
group: group
groups_and_categories: Groups and Categories
intro: Visualize the panorama of ontologies and other semantic resources of %{site} via metadata aggregation.
intro: Visualize the panorama of all ontologies on %{site} via metadata aggregation.
more_properties_charts: More properties charts
most_active_ontologies: Most active ontologies
most_active_organizations: Most active organizations
Expand Down Expand Up @@ -461,6 +482,7 @@ en:
login: Login
logout: Logout
mappings: Mappings
recommender: Recommender
publications: Publications
release_notes: Release Notes
search_prompt: Search in %{portal_name} ...
Expand Down Expand Up @@ -896,26 +918,26 @@ en:
mailing_list_description: Register to the %{portal} announcements mailing list.
api_key_description: Your API Key can be used to access %{portal} Web services
api_documentation: API documentation
custom_semantic_resource: Custom semantic resource set
custom_semantic_resource: Custom ontology set
please: Please
modify_custom_semantic_resource: |
visit the main site
to modify your Custom Semantic Resource Set.
customize_portal_display: "Customize your %{portal} display: Pick the semantic resources that you want to see on %{portal} will hide all other semantic resources."
select_semantic_resources : Select semantic resources
no_semantic_resources: You haven't picked any semantic resources yet
to modify your Custom Ontology Set.
customize_portal_display: "Customize your %{portal} display: Pick the ontologies that you want to see on %{portal} will hide all other ontologies."
select_semantic_resources : Select ontologies
no_semantic_resources: You haven't picked any ontologies yet
note_feature_logged_in: "Note: this feature works only when you are logged in."
select_custom_semantic_resources: Select custom semantic resources
save_custom_semantic_resources: Save custom semantic resources
not_subscribed: Not subscribed to any semantic resource
submitted_semantic_resources: Submitted Semantic Resources
upload_semantic_resources: Upload semantic resources
select_custom_semantic_resources: Select custom ontologies
save_custom_semantic_resources: Save custom ontologies
not_subscribed: Not subscribed to any ontology
submitted_semantic_resources: Submitted Ontologies
upload_semantic_resources: Upload Ontologies
projects_created: Projects Created
no_project_created: No project created
unsubscribe: Unsubscribe
subscribe: Subscribe
subscriptions: Subscriptions
no_uploaded_resources: You didn't upload any semantic resource yet
no_uploaded_resources: You didn't upload any ontology yet
notes: Notes

reproduce_results: 'Reproduce these results using the '
Expand Down Expand Up @@ -1381,7 +1403,7 @@ en:
dates: Dates
person_and_organization: Persons and organizations
other_links: Other links
info_tooltip_links: Metadata properties that highlight the links enabling access to datasets, downloading semantic resources, etc
info_tooltip_links: Metadata properties that highlight the links enabling access to datasets, downloading ontologies, etc
projects_and_usage_information: Projects and usage information
info_tooltip_projects: Details pertaining to the utilization of the ontology.
methodology_and_provenance: Methodology and provenance
Expand Down
Loading

0 comments on commit 94c067e

Please sign in to comment.