Commit Graph

11202 Commits

Author SHA1 Message Date
Consul Bot
4ae0f37d41 New translations responders.yml (Chinese Simplified) 2018-10-25 04:00:26 +02:00
Consul Bot
2557852830 New translations responders.yml (Chinese Simplified) 2018-10-25 03:56:51 +02:00
Consul Bot
9cd3c6e6d1 New translations rails.yml (Chinese Simplified) 2018-10-25 03:50:36 +02:00
Consul Bot
8e3b87638c New translations pages.yml (Chinese Simplified) 2018-10-25 03:30:31 +02:00
Consul Bot
2d8794d2c3 New translations rails.yml (Chinese Simplified) 2018-10-25 03:30:29 +02:00
Consul Bot
cc44ecc364 New translations pages.yml (Chinese Simplified) 2018-10-25 03:20:26 +02:00
Consul Bot
487ec20f49 New translations pages.yml (Chinese Simplified) 2018-10-25 03:10:25 +02:00
Consul Bot
5246839ca5 New translations pages.yml (Chinese Simplified) 2018-10-25 02:59:55 +02:00
Consul Bot
8b9a462b7a New translations pages.yml (Chinese Simplified) 2018-10-25 02:50:29 +02:00
Consul Bot
f52810219a New translations pages.yml (Chinese Simplified) 2018-10-25 02:35:08 +02:00
Consul Bot
6791ffd723 New translations pages.yml (Chinese Simplified) 2018-10-25 02:28:28 +02:00
Consul Bot
f49773ba45 New translations pages.yml (Chinese Simplified) 2018-10-25 02:20:57 +02:00
Consul Bot
2f8d705ee2 New translations pages.yml (Chinese Simplified) 2018-10-24 00:40:42 +02:00
Consul Bot
252991de37 New translations moderation.yml (Chinese Simplified) 2018-10-24 00:40:40 +02:00
Consul Bot
5fb40f929f New translations moderation.yml (Chinese Simplified) 2018-10-23 17:50:56 +02:00
Javi Martín
9404cb8b3a Fix bug with non-underscored locales
Ruby can't have hyphens in method names, so sending something like
`record.title_pt-BR` would raise an exception.

Using globalize's `localized_attr_name_for` method fixes the bug.

Thanks Marko for the tip.
2018-10-23 16:29:14 +02:00
Javi Martín
934bce5932 Don't abort the migration if the simulation fails
We think aborting the migration will generate more headaches to system
administrators, who will have to manually check and fix every invalid
record before anything can be migrated.
2018-10-23 16:29:14 +02:00
Javi Martín
7fff57a25f Add task to simulate data migration
This way we can check everything is OK before actually migrating the
data to the translations tables.
2018-10-23 16:29:14 +02:00
Javi Martín
3c48059f07 Log failed data migrations
In theory, it should never happen, but that's why exceptions exist.
2018-10-23 16:29:13 +02:00
Javi Martín
be25e5fc45 Use migrate_data option for globalize
This way the task to migrate the data doesn't have to be run manually if
these migrations weren't already executed.
2018-10-23 16:29:13 +02:00
Javi Martín
a84a0f2b7d Migrate custom pages data to their locale 2018-10-23 16:29:13 +02:00
Javi Martín
ef7be4fc55 Add task to migrate data to translation tables
We forgot to do it when we created the translation tables, and so now we
need to make sure we don't overwrite existing translations.
2018-10-23 16:29:13 +02:00
Javi Martín
ccdbdb26ba Fix poll question with non-underscored locales
Ruby can't have hyphens in method names, so sending something like
`title_pt-BR=` would raise an exception.
2018-10-23 14:23:10 +02:00
Javi Martín
b8673c1cbf Fix spec assuming German isn't available
Since we've recently added German to the available languages, and we
might support every language in the future, we're using the fictional
world language to check a locale which isn't available.

Another option could be to set the available locales in the test
environment (or the rspec helper), but then we'd have to make sure it's
executed before the call to `globalize_accessors` in the model, and it
might be confusing for developers.
2018-10-23 13:58:22 +02:00
Consul Bot
f2c7fe787a New translations pages.yml (Chinese Simplified) 2018-10-23 02:10:32 +02:00
Consul Bot
8293dcf0ad New translations pages.yml (Chinese Simplified) 2018-10-23 02:00:38 +02:00
Consul Bot
78e3e3f541 New translations pages.yml (Chinese Simplified) 2018-10-23 01:51:01 +02:00
Consul Bot
60b9be142b New translations pages.yml (Chinese Simplified) 2018-10-23 01:40:35 +02:00
Consul Bot
72392f6104 New translations pages.yml (Chinese Simplified) 2018-10-23 01:30:29 +02:00
Consul Bot
d268f9747d New translations pages.yml (Chinese Simplified) 2018-10-23 01:25:04 +02:00
Consul Bot
e3d3779395 New translations officing.yml (Chinese Simplified) 2018-10-22 20:50:44 +02:00
Consul Bot
96c2d4c295 New translations pages.yml (Chinese Simplified) 2018-10-22 20:50:43 +02:00
Javi Martín
2a1b50beba Extract method to render form fields for a locale 2018-10-22 16:36:18 +02:00
Javi Martín
361a15640f Use detect instead of select.first 2018-10-22 16:36:18 +02:00
Javi Martín
93a7cb6c0f Simplify code checking whether to enable a locale 2018-10-22 16:36:18 +02:00
Javi Martín
f5bb3c64a1 Don't run specs if there are custom fallbacks
This spec depends on French falling back to Spanish and was failing on
forks using a different fallback.
2018-10-22 16:36:18 +02: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
Javi Martín
5e8746f026 Remove question option uniqueness validation
Having translations makes this validation too complex and not worth the
effort, since now we can't just scope in a single column but we need to
scope in the translations locale and the question ID.
2018-10-22 16:36:18 +02:00
Javi Martín
9105ac3a69 Prefix classes used in JavaScript with "js-"
The same way it's done in the rest of the application.
2018-10-22 16:36:18 +02:00
Javi Martín
1895e2dd2f Make it easier to know destroy_field is an input
By using the input and finding it by its name, it's easier to see the
difference between this input and the delete-language link.
2018-10-22 16:36:18 +02:00
Javi Martín
dbea577062 Follow naming conventions for HTML classes and IDs
We use underscores for IDs and hyphens for classes.
2018-10-22 16:36:18 +02:00
Javi Martín
08c043425a Remove reference to site customization page locale
We don't use that attribute since we added translations for this model.
2018-10-22 16:36:18 +02:00
Javi Martín
5511a3a194 Fix "Add option" link position
The new options were being added inside the `.column` div, when they
needed to be added before it.
2018-10-22 16:36:17 +02:00
Javi Martín
01315f2695 Fix rubocop line too long warning 2018-10-22 16:36:17 +02:00
Javi Martín
0505028d77 Extract method in translatable builder
This way we fix the rubocop warning for line too long and make the code
a bit easier to read.
2018-10-22 16:36:17 +02:00
Javi Martín
f1ccdb87b1 Fix removing an option for legislation questions
We were allowing the `_destroy` field for translations, but not for the
options themselves.
2018-10-22 16:36:17 +02:00
Javi Martín
6952c9c9db Fix legislation options not being updated
We broke this behaviour by introducing translations and not allowing the
`id` parameter anymore.
2018-10-22 16:36:17 +02:00
Javi Martín
3db145d5db Simplify creating a process in questions specs 2018-10-22 16:36:17 +02:00
Javi Martín
34b5a88564 Fix updating translatables without current locale
The current locale wasn't being marked for destruction and so saving
the record tried to create a new translation for the current locale.
2018-10-22 16:36:17 +02:00
Javi Martín
21cf39d5ed Fix alignment in last translatable fields
When we grouped the fields together, the last one turned into a
`last-child`, which foundation automatically aligns to the right.

The markdown editor also needed to be tweaked a little bit.
2018-10-22 16:36:17 +02:00