Commit Graph

87 Commits

Author SHA1 Message Date
Javi Martín
6fd9a286d7 Don't access the database in after_initialize
Rails 5.2 crashes in the `db:create` task because it tries to run the
`after_initialize` block before the database is created.

The easiest way to solve it is to move the code out of the initializer
and calculate the API type definitions on demand. Note results are still
cached using a class instance variable (not to be confused with a class
variable), and so once definitions are obtained, they will remain
constant until the application is restarted, even in the development
environment.
2020-07-08 18:34:58 +02:00
Javi Martín
0b1a4907ac Load custom locales after everything is loaded
The line:

```
config.i18n.load_path += Dir[Rails.root.join("config", "locales", "**", "*.{rb,yml}")]
```

Was adding every locale under the `config/locales` folder, including the
ones inside `config/locales/custom/`. The files were loaded in the same
order as listed using `ls -f`.

So if the custom locales were loaded before the folder
`config/locales/#{I18n.locale}`, the default locales would override the
custom ones, and we want the custom locales to override the default
ones so CONSUL is easier to customize.
2019-08-07 22:05:01 +02:00
Senén Rodero Rodríguez
5d0b74cb07 Initialize graphql after application initialization
Proposal, Debate and Comment "globalize_accessors" class method were
loaded before application available locales initialization because of
graphql initializer. This will cause unexpected translation errors at
any translatable classes declared at graphql api definition (api.yml).

Doing GraphQL initialization after application initialization should
solve this issue.
2019-06-27 09:19:35 +02:00
voodoorai2000
78f3cec133 Add Bosnian, Czech, Danish, Greek, Croatian and Turkish locales 2019-05-31 14:49:38 +02:00
decabeza
cb22e6cbfb Merge branch 'master' into proposal-dashboard 2019-04-23 17:12:47 +02:00
Javi Martín
4adf712c26 Prepend custom assets to CONSUL assets
Rails 5 changed the initialization order, and now our initializers were
running before the `append_assets_path` initializer for each engine,
which prepended application assets to the custom assets we prepended in
the initializer.

Moving the code to the `config.after_initialize` code didn't work
either, since the paths added there were ignored by the application.

Adding another initializer to the Rails Engine is a hack, but solves the
problem.
2019-04-17 17:40:57 +02:00
alejandro
b7a9995b38 fixes deprecation warning relate to raise_in_transactional_callbacks
As described in
http://edgeguides.rubyonrails.org/5_0_release_notes.html#active-record-notable-changes
2019-04-17 17:40:55 +02:00
Juanjo Bazán
eb36b7e2e5 updates config files 2019-04-16 17:28:06 +02:00
decabeza
eda6ea7f12 Merge branch 'master' into dashboard 2019-03-26 16:45:48 +01:00
Julian Herrero
c9cdc72537 Use double quotes in config/ 2019-03-15 10:29:07 +01:00
voodoorai2000
4db07a3341 Update available locales
Add locales for Indonesian, Russian, Slovak and Somali.
2019-02-15 15:25:40 +01:00
Javi Martín
2e6644d513 Fix crash with no translation for default locale
When we were visiting a page showing the content of a record which uses
globalize and our locale was the default one and there was no
translation for the default locale, the application was crashing in some
places because there are no fallbacks for the default locale.

For example, when visiting a legislation process, the line with
`CGI.escape(title)` was crashing because `title` was `nil` for the
default locale.

We've decided to solve this issue by using any available translations as
globalize fallbacks instead of showing a 404 error or a translation
missing error because these solutions would (we thinkg) either require
modifying many places in the application or making the translatable
logic even more complex.

Initially we tried to add this solution to an initializer, but it must
be called after initializing the application so I18n.fallbacks[locale]
gets the value defined in config.i18n.fallbacks.

Also note the line:

fallbacks[locale] = I18n.fallbacks[locale] + I18n.available_locales

Doesn't mention `I18n.default_locale` because the method
`I18n.fallbacks[locale]` automatically adds the default locale.
2018-10-22 16:36:18 +02:00
decabeza
546105d989 Merge branch 'master' into dashboard-master 2018-10-19 01:48:37 +02:00
voodoorai2000
8eb399150e Remove fallback rules for locales not yet added 2018-10-17 12:47:35 +02:00
voodoorai2000
3b8bb5038d Add fallback i18n locales
All other languages will fallback to the default locale

Rails also, seems to pick up dialect fallbacks, for locales with this format: es-CO, es-PE, etc, which will fallback to "es", so that is great 😌
2018-10-17 12:47:35 +02:00
voodoorai2000
f2fe230a15 Add all available locales
Only addding those with significant number of translations
2018-10-17 12:47:35 +02:00
Juan Salvador Pérez García
921d567110 Implements #175
General menu has been refactored to look like the mockups.
The progress menu has been refactored as well.
2018-07-17 17:57:30 +02:00
Alberto Calderón Queimadelos
0e1d5d95a7 Revert "Make config.time_zone configurable at secrets.yml" 2018-03-08 17:12:00 +01:00
Bertocq
f9909573a3 Make config.time_zone configurable at secrets.yml 2018-03-05 11:17:25 +01:00
Bertocq
18a5bc6642 Make English the default locale 2018-01-24 11:37:43 +01:00
decabeza
5949f7abf0 uppercase all consul name 2017-09-01 12:51:31 +02:00
Bertocq
552661f0e4 Add to i18n load path files in nested folders 2017-07-05 13:30:05 +02:00
Tom Demeyer
3ba5e25801 enable dutch translation 2017-04-28 15:53:15 +02:00
rgarcia
d540be333a Makes tolk aware of french and portuguese translations 2016-10-31 11:54:26 +01:00
rgarcia
aeec264b8b makes fallback locale spanish 2016-10-31 11:50:16 +01:00
rgarcia
04ca5f7ae8 adds french and brazilian portuguese locales 2016-10-31 11:50:07 +01:00
Ignacio Aliende García
e4e2706af6 Fixes custom locales inclusion. 2016-09-20 17:34:26 +01:00
Andrés Pereira
a4dbd768ce Custom folder structure: initial documentation, code and structure folders 2016-05-31 19:57:29 +02:00
Juanjo Bazán
b946f31fc7 changes 'participacion' to 'consul' in config 2015-11-23 14:10:46 +01:00
rgarcia
8a950761d3 configures delayed_jobs 2015-09-03 22:47:54 +02:00
rgarcia
cc1e1aab60 fixes specs
for vampires
2015-08-15 01:55:39 +02:00
kikito
17fb44c70b Moves i18n initialisation to application.rb 2015-08-06 18:31:44 +02:00
rgarcia
90720457bd moves wysiwyg sanitizer to lib [#71] 2015-07-31 18:51:20 +02:00
kikito
8d9f9a21a4 Autoloads app/services 2015-07-31 16:09:50 +02:00
Alberto García Cabeza
68c45198c6 Includes fonts files 2015-07-24 11:50:08 +02:00
rgarcia
c2d5b36fb5 makes default language spanish [#5] 2015-07-16 19:22:58 +02:00
rgarcia
8db3630837 initial commit 2015-07-15 13:32:13 +02:00