Skip to content

Commit

Permalink
WiceGrid supports loalization via Rails I18n
Browse files Browse the repository at this point in the history
  • Loading branch information
leikind committed Nov 8, 2009
1 parent c5815ce commit 1a14444
Show file tree
Hide file tree
Showing 11 changed files with 329 additions and 81 deletions.
Expand Up @@ -5,9 +5,8 @@
# +true+ will allow to embed erb content in column (cell) definitions.
Wice::Defaults::ERB_MODE = false


# Default number of rows to show per page.
Wice::Defaults::PER_PAGE = 10
Wice::Defaults::PER_PAGE = 20

# Default order direction
Wice::Defaults::ORDER_DIRECTION = 'asc'
Expand All @@ -23,9 +22,6 @@

Wice::Defaults::SHOW_HIDE_FILTER_ICON = 'icons/grid/page_white_find.png'

Wice::Defaults::SHOW_FILTER_TOOLTIP = 'Show filter'
Wice::Defaults::HIDE_FILTER_TOOLTIP = 'Hide filter'
Wice::Defaults::CSV_EXPORT_TOOLTIP = 'Export to CSV'

# Icon to trigger filtering.
Wice::Defaults::FILTER_ICON = 'icons/grid/table_refresh.png'
Expand All @@ -40,14 +36,10 @@
Wice::Defaults::CSV_EXPORT_ICON = "/images/icons/grid/page_white_excel.png"


Wice::Defaults::FILTER_TOOLTIP = "Filter"
Wice::Defaults::RESET_FILTER_TOOLTIP = "Reset"

# The label of the first option of a custom dropdown list meaning 'All items'
Wice::Defaults::CUSTOM_FILTER_ALL_LABEL = '--'

Wice::Defaults::BOOLEAN_FILTER_TRUE_LABEL = 'yes'
Wice::Defaults::BOOLEAN_FILTER_FALSE_LABEL = 'no'

# Allow switching between a single and multiple selection modes in custom filters (dropdown boxes)
Wice::Defaults::ALLOW_MULTIPLE_SELECTION = true
Expand All @@ -63,7 +55,7 @@
# * <tt>:when_filtered</tt> - when the table is the result of filtering
# * <tt>:always</tt> - show the filter always
# * <tt>:no</tt> - never show the filter
Wice::Defaults::SHOW_FILTER = :when_filtered
Wice::Defaults::SHOW_FILTER = :always

# SQL operator used for matching strings in string filters.
Wice::Defaults::STRING_MATCHING_OPERATOR = 'LIKE'
Expand All @@ -78,20 +70,14 @@
'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter' => 'ILIKE'
}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# will_paginate #

Wice::Defaults::PREVIOUS_LABEL = '« Previous'
Wice::Defaults::NEXT_LABEL = 'Next »'

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Advanced Filters #

# Switch of the negation checkbox in all text filters
Wice::Defaults::NEGATION_IN_STRING_FILTERS = true
Wice::Defaults::NEGATION_IN_STRING_FILTERS = false

# The title of the checkox to turn on negation
Wice::Defaults::NEGATION_CHECKBOX_TITLE = 'Exclude'


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Expand All @@ -103,20 +89,6 @@
# If number of all queries is more than this value, the user will be given a warning message
Wice::Defaults::START_SHOWING_WARNING_FROM = 100

# link to switch to "ahow all records"
Wice::Defaults::SHOW_ALL_RECORDS_LABEL = 'show all'

# tooltip for the link to switch to "ahow all records"
Wice::Defaults::SHOW_ALL_RECORDS_TOOLTIP = 'Show all records'

# Warning message shown when the user wants to switch to all-records mode
Wice::Defaults::ALL_QUERIES_WARNING = 'Are you sure you want to display all records?'

# link to paginated view
Wice::Defaults::SWITCH_BACK_TO_PAGINATED_MODE_LABEL = "back to paginated view"

# tooltip for the link to paginated view
Wice::Defaults::SWITCH_BACK_TO_PAGINATED_MODE_TOOLTIP = "Switch back to the view with pages"

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Saving Queries #
Expand All @@ -128,18 +100,6 @@
# QUERY_STORE_MODEL = 'WiceGridSerializedQuery'
Wice::Defaults::QUERY_STORE_MODEL = 'SavedQuery'

Wice::Defaults::SAVED_QUERY_PANEL_TITLE = 'Saved Queries'
Wice::Defaults::SAVE_QUERY_BUTTON_LABEL = 'Save the state of filters'

Wice::Defaults::SAVED_QUERY_DELETION_CONFIRMATION = 'Are you sure?'
Wice::Defaults::SAVED_QUERY_DELETION_LINK_TITLE = 'Delete query'
Wice::Defaults::SAVED_QUERY_LINK_TITLE = 'Load query'

Wice::Defaults::VALIDATES_UNIQUENESS_ERROR = "A query with this name already exists"
Wice::Defaults::VALIDATES_PRESENCE_ERROR = "Please sumbit the name of the custom query"

Wice::Defaults::QUERY_DELETED_MESSAGE = "Saved query deleted."
Wice::Defaults::QUERY_SAVED_MESSAGE = "Query saved."

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Here go settings related to the calendar helpers #
Expand Down Expand Up @@ -172,11 +132,64 @@
# Icon to popup the calendar.
Wice::Defaults::CALENDAR_ICON = "/images/icons/grid/calendar_view_month.png"



######## Messages ########

Wice::Defaults::SHOW_FILTER_TOOLTIP = 'Show filter'
Wice::Defaults::HIDE_FILTER_TOOLTIP = 'Hide filter'
Wice::Defaults::CSV_EXPORT_TOOLTIP = 'Export to CSV'

Wice::Defaults::FILTER_TOOLTIP = "Filter"
Wice::Defaults::RESET_FILTER_TOOLTIP = "Reset"

Wice::Defaults::BOOLEAN_FILTER_TRUE_LABEL = 'yes'
Wice::Defaults::BOOLEAN_FILTER_FALSE_LABEL = 'no'

Wice::Defaults::PREVIOUS_LABEL = '« Previous'
Wice::Defaults::NEXT_LABEL = 'Next »'

# Title of the icon clicking on which will show the calendar to set the FROM date.
Wice::Defaults::DATE_SELECTOR_TOOLTIP_FROM = 'From'
# Title of the icon clicking on which will show the calendar to set the TO date.
Wice::Defaults::DATE_SELECTOR_TOOLTIP_TO = 'To'

# The title of the checkox to turn on negation
Wice::Defaults::NEGATION_CHECKBOX_TITLE = 'Exclude'

# link to switch to "show all records"
Wice::Defaults::SHOW_ALL_RECORDS_LABEL = 'show all'

# tooltip for the link to switch to "show all records"
Wice::Defaults::SHOW_ALL_RECORDS_TOOLTIP = 'Show all records'

# Warning message shown when the user wants to switch to all-records mode
Wice::Defaults::ALL_QUERIES_WARNING = 'Are you sure you want to display all records?'

# link to paginated view
Wice::Defaults::SWITCH_BACK_TO_PAGINATED_MODE_LABEL = "back to paginated view"

# tooltip for the link to paginated view
Wice::Defaults::SWITCH_BACK_TO_PAGINATED_MODE_TOOLTIP = "Switch back to the view with pages"

# Title of the date string.
Wice::Defaults::DATE_STRING_TOOLTIP = 'Click to delete'


Wice::Defaults::SAVED_QUERY_PANEL_TITLE = 'Saved Queries'
Wice::Defaults::SAVE_QUERY_BUTTON_LABEL = 'Save the state of filters'

Wice::Defaults::SAVED_QUERY_DELETION_CONFIRMATION = 'Are you sure?'
Wice::Defaults::SAVED_QUERY_DELETION_LINK_TITLE = 'Delete query'
Wice::Defaults::SAVED_QUERY_LINK_TITLE = 'Load query'

Wice::Defaults::VALIDATES_UNIQUENESS_ERROR = "A query with this name already exists"
Wice::Defaults::VALIDATES_PRESENCE_ERROR = "Please sumbit the name of the custom query"

Wice::Defaults::QUERY_DELETED_MESSAGE = "Saved query deleted."
Wice::Defaults::QUERY_SAVED_MESSAGE = "Query saved."

######## Messages END ########


end
155 changes: 155 additions & 0 deletions generators/wice_grid_assets/templates/locales/wice_grid.yml
@@ -0,0 +1,155 @@
en:
wice_grid:
show_filter_tooltip: Show filter
hide_filter_tooltip: Hide filter
csv_export_tooltip: Export to CSV
filter_tooltip: Filter
reset_filter_tooltip: Reset
boolean_filter_true_label: yes
boolean_filter_false_label: no
previous_label: « Previous
next_label: Next »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: From
# Title of the icon clicking on which will show the calendar to set the TO date.
date_selector_tooltip_to: To
# The title of the checkox to turn on negation
negation_checkbox_title: Exclude
# link to switch to show all records
show_all_records_label: show all
# tooltip for the link to switch to show all records
show_all_records_tooltip: Show all records
# Warning message shown when the user wants to switch to all-records mode
all_queries_warning: Are you sure you want to display all records?
# link to paginated view
switch_back_to_paginated_mode_label: back to paginated view
# tooltip for the link to paginated view
switch_back_to_paginated_mode_tooltip: Switch back to the view with pages
# Title of the date string.
date_string_tooltip: Click to delete
saved_query_panel_title: Saved Queries
save_query_button_label: Save the state of filters
saved_query_deletion_confirmation: Are you sure?
saved_query_deletion_link_title: Delete query
saved_query_link_title: Load query
validates_uniqueness_error: A query with this name already exists
validates_presence_error: Please sumbit the name of the custom query
query_deleted_message: Saved query deleted.
query_saved_message: Query saved.

nl:
wice_grid:
show_filter_tooltip: Filter tonen
hide_filter_tooltip: Filter verbergen
csv_export_tooltip: Als CSV exporteren
filter_tooltip: Filter
reset_filter_tooltip: Terugstellen
boolean_filter_true_label: ja
boolean_filter_false_label: neen
previous_label: « Vorige
next_label: Volgende »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: Vanaf
# Title of the icon clicking on which will show the calendar to set the TO date.
date_selector_tooltip_to: Tot
# The title of the checkox to turn on negation
negation_checkbox_title: Uitsluiten
# link to switch to show all records
show_all_records_label: Alle rijen tonen
# tooltip for the link to switch to show all records
show_all_records_tooltip: Alle rijen tonen
# Warning message shown when the user wants to switch to all-records mode
all_queries_warning: Bent u zeker dat u alle rijen wilt tonen?
# link to paginated view
switch_back_to_paginated_mode_label: Terug naar pagina's
# tooltip for the link to paginated view
switch_back_to_paginated_mode_tooltip: Terug naar pagina's
# Title of the date string.
date_string_tooltip: Klik om te verwijderen
saved_query_panel_title: Opgeslagen query's
save_query_button_label: Query opslaan
saved_query_deletion_confirmation: Bent u zeker?
saved_query_deletion_link_title: Query verwijderen
saved_query_link_title: Query laden
validates_uniqueness_error: Deze query bestaat reeds
validates_presence_error: Gelieve de naam van de query in te vullen
query_deleted_message: Opgeslagen query verwijderd.
query_saved_message: Query opgeslagen

fr:
wice_grid:
show_filter_tooltip: Afficher le filtre
hide_filter_tooltip: Cacher le filtrer
csv_export_tooltip: Exporter en CSV
filter_tooltip: Filtrer
reset_filter_tooltip: Reset
boolean_filter_true_label: oui
boolean_filter_false_label: non
previous_label: « Page précédente
next_label: Page suivante »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: De
# Title of the icon clicking on which will show the calendar to set the TO date.
date_selector_tooltip_to: à
# The title of the checkox to turn on negation
negation_checkbox_title: Exclure
# link to switch to show all records
show_all_records_label: Voir tous
# tooltip for the link to switch to show all records
show_all_records_tooltip: Voir tous les enregistrements
# Warning message shown when the user wants to switch to all-records mode
all_queries_warning: Etes-vous certain de vouloir afficher tous les enregistrements?
# link to paginated view
switch_back_to_paginated_mode_label: Retour à la vue paginée
# tooltip for the link to paginated view
switch_back_to_paginated_mode_tooltip: Retour à la vue par pages
# Title of the date string.
date_string_tooltip: Cliquez pour effacer
saved_query_panel_title: Requêtes sauvées
save_query_button_label: Sauver l'état des filtres
saved_query_deletion_confirmation: Etes vous sûr?
saved_query_deletion_link_title: Effacer la requête
saved_query_link_title: Charger la requête
validates_uniqueness_error: Un requête existante porte déjà ce nom
validates_presence_error: Veuillez indiquer le nom de la requête que vous souhaitez sauver
query_deleted_message: La requête a été effacée.
query_saved_message: La requête a été sauvée.

ru:
wice_grid:
show_filter_tooltip: Показать фильтр
hide_filter_tooltip: Спрятать фильтр
csv_export_tooltip: Экспорт в CSV
filter_tooltip: Фильтровать
reset_filter_tooltip: Сброс
boolean_filter_true_label: да
boolean_filter_false_label: нет
previous_label: « Предыдущая
next_label: Следующая »
# Title of the icon clicking on which will show the calendar to set the FROM date.
date_selector_tooltip_from: С
# Title of the icon clicking on which will show the calendar to set the TO date.
date_selector_tooltip_to: До
# The title of the checkox to turn on negation
negation_checkbox_title: Исключая строки
# link to switch to show all records
show_all_records_label: показать все
# tooltip for the link to switch to show all records
show_all_records_tooltip: Показать все записи
# Warning message shown when the user wants to switch to all-records mode
all_queries_warning: Вы уверены в том, что хотите отобразить все записи?
# link to paginated view
switch_back_to_paginated_mode_label: Назад к постраничному выводу
# tooltip for the link to paginated view
switch_back_to_paginated_mode_tooltip: Назад к постраничному выводу
# Title of the date string.
date_string_tooltip: Кликните, чтобы удалить дату
saved_query_panel_title: Сохранённые фильтры
save_query_button_label: Сохранить фильтр
saved_query_deletion_confirmation: Вы уверены?
saved_query_deletion_link_title: Удалить сохранённый фильтр
saved_query_link_title: Загрузить сохранённый фильтр
validates_uniqueness_error: Сохранённый фильтр с таким именем уже существует
validates_presence_error: Пожалуйста введите имя сохраняемого фильтра
query_deleted_message: Сохранённый фильтр удалён.
query_saved_message: Сохранённый фильтр сохранён.
4 changes: 4 additions & 0 deletions generators/wice_grid_assets/wice_grid_assets_generator.rb
Expand Up @@ -5,6 +5,10 @@ def manifest
m.directory "config/initializers"
m.file "initializers/wice_grid_config.rb", "config/initializers/wice_grid_config.rb"

# wice_grid locales
m.directory "config/locales"
m.file "locales/wice_grid.yml", "config/locales/wice_grid.yml"

# wice_grid js & css
m.file "javascripts/wice_grid.js", "public/javascripts/wice_grid.js"
m.file "stylesheets/wice_grid.css", "public/stylesheets/wice_grid.css"
Expand Down
9 changes: 5 additions & 4 deletions lib/grid_renderer.rb
Expand Up @@ -79,10 +79,11 @@ def each_column_with_attribute #:nodoc:

def csv_export_icon #:nodoc:
if @grid.export_to_csv_enabled
tooltip = WiceGridNlMessageProvider.get_message(:CSV_EXPORT_TOOLTIP)
link_to_function(
image_tag(Defaults::CSV_EXPORT_ICON,
:title => Defaults::CSV_EXPORT_TOOLTIP,
:alt => Defaults::CSV_EXPORT_TOOLTIP), "#{grid.name}.export_to_csv()")
:title => tooltip,
:alt => tooltip), "#{grid.name}.export_to_csv()")
else
nil
end
Expand Down Expand Up @@ -210,8 +211,8 @@ def column(opts = {}, &block)
:allow_multiple_selection => Defaults::ALLOW_MULTIPLE_SELECTION,
:allow_ordering => true,
:attribute_name => nil,
:boolean_filter_false_label => Defaults::BOOLEAN_FILTER_FALSE_LABEL,
:boolean_filter_true_label => Defaults::BOOLEAN_FILTER_TRUE_LABEL,
:boolean_filter_false_label => WiceGridNlMessageProvider.get_message(:BOOLEAN_FILTER_FALSE_LABEL),
:boolean_filter_true_label => WiceGridNlMessageProvider.get_message(:BOOLEAN_FILTER_TRUE_LABEL),
:class => nil,
:column_name => '',
:custom_filter => nil,
Expand Down

0 comments on commit 1a14444

Please sign in to comment.