- name: Prepare Database
run: |
docker compose run --rm web bundle exec rails db:migrate
- docker compose run --rm web bundle exec rails i18n:js:export
+ docker compose run --rm web bundle exec i18n export
docker compose run --rm web bundle exec rails assets:precompile
docker compose run --rm web osmosis --rx docker/null-island.osm.xml --wd host=db database=openstreetmap user=openstreetmap password=openstreetmap validateSchemaVersion=no
- name: Test Basic Website
bundle exec rails db:migrate
sed -f script/normalise-structure db/structure.sql > db/structure.actual
diff -uw db/structure.expected db/structure.actual
- - name: Export javascript strings
- run: bundle exec rails i18n:js:export
- name: Install node modules
run: bundle exec bin/yarn install
+ - name: Export javascript strings
+ run: bundle exec i18n export
- name: Compile assets
run: bundle exec rails assets:precompile
- name: Create tmp/pids directory
.ruby-gemset
.ruby-version
.vagrant
-app/assets/javascripts/i18n
+app/assets/javascripts/i18n/*.js
config/credentials.yml.enc
config/master.key
config/environments/*.local.yml
config/settings/*.local.yml
coverage
doc
+i18n/data
log
node_modules
public/assets
* It's not recommended to use `rails server` in production. Our recommended approach is to use [Phusion Passenger](https://www.phusionpassenger.com/). Instructions are available for [setting it up with most web servers](https://www.phusionpassenger.com/documentation_and_support#documentation).
* Passenger will, by design, use the Production environment and therefore the production database - make sure it contains the appropriate data and user accounts.
* The included version of the map call is quite slow and eats a lot of memory. You should consider using [CGIMap](https://github.com/zerebubuth/openstreetmap-cgimap) instead.
-* Make sure you generate the i18n files and precompile the production assets: `RAILS_ENV=production rails i18n:js:export assets:precompile`
+* Make sure you generate the i18n files and precompile the production assets: `RAILS_ENV=production bundle exec i18n export; bundle exec rails assets:precompile`
* Make sure the web server user as well as the rails user can read, write and create directories in `tmp/`.
gem "dry-validation"
gem "frozen_record"
gem "http_accept_language", "~> 2.1.1"
-gem "i18n-js", "~> 3.9.2"
+gem "i18n-js", "~> 4.2.3"
gem "openstreetmap-deadlock_retry", ">= 1.3.1", :require => "deadlock_retry"
gem "rack-cors"
gem "rails-i18n", "~> 7.0.0"
git (1.19.1)
addressable (~> 2.8)
rchardet (~> 1.8)
+ glob (0.4.1)
globalid (1.2.1)
activesupport (>= 6.1)
google-protobuf (3.25.6)
http_accept_language (2.1.1)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
- i18n-js (3.9.2)
- i18n (>= 0.6.6)
+ i18n-js (4.2.3)
+ glob (>= 0.4.0)
+ i18n
i18n-tasks (1.0.15)
activesupport (>= 4.0.2)
ast (>= 2.1.0)
gd2-ffij (>= 0.4.0)
htmlentities
http_accept_language (~> 2.1.1)
- i18n-js (~> 3.9.2)
+ i18n-js (~> 4.2.3)
i18n-tasks
image_optim_rails
image_processing
const application_data = $("head").data();
const locale = application_data.locale;
- OSM.i18n = I18n;
-
- OSM.i18n.default_locale = OSM.DEFAULT_LOCALE;
- OSM.i18n.locale = locale;
+ OSM.i18n.defaultLocale = OSM.DEFAULT_LOCALE;
+ OSM.i18n.locale = application_data.locale;
// '-' are replaced with '_' in https://github.com/eemeli/make-plural/tree/main/packages/plurals
const pluralizer = plurals[locale.replace(/\W+/g, "_")] || plurals[locale.split("-")[0]];
if (pluralizer) {
- OSM.i18n.pluralization[locale] = (count) => [pluralizer(count), "other"];
+ OSM.i18n.pluralization.register(locale, (_, count) => [pluralizer(count), "other"]);
}
OSM.preferred_editor = application_data.preferredEditor;
//= require i18n
//= require i18n/embed
-const OSM = { i18n: I18n };
-
if (navigator.languages) {
OSM.i18n.locale = navigator.languages[0];
} else if (navigator.language) {
OSM.i18n.locale = navigator.language;
}
-OSM.i18n.default_locale = <%= I18n.default_locale.to_json %>;
-OSM.i18n.fallbacks = true;
+OSM.i18n.defaultLocale = <%= I18n.default_locale.to_json %>;
+OSM.i18n.enableFallback = true;
window.onload = function () {
const args = Object.fromEntries(new URLSearchParams(location.search));
--- /dev/null
+//= require i18n-js/dist/browser/index.js
+
+if (typeof OSM === "undefined") {
+ OSM = {};
+}
+
+OSM.i18n = new I18n.I18n();
# Suppress logger output for asset requests.
config.assets.quiet = true
- # Export translations automatically.
- config.middleware.use I18n::JS::Middleware
-
# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true
# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []
- # Export translations automatically.
- config.middleware.use I18n::JS::Middleware
-
# Raises error for missing translations.
config.i18n.raise_on_missing_translations = true
+++ /dev/null
-export_i18n_js: false
-
-translations:
- - file: "app/assets/javascripts/i18n/%{locale}.js"
- pretty_print: true
- only:
- - "*.date"
- - "*.time"
- - "*.browse.start_rjs.*"
- - "*.javascripts.*"
- - "*.site.edit.*"
- - "*.site.index.remote_failed"
- - "*.site.sidebar.search_results"
- - "*.diary_entries.edit.marker_text"
- - "*.layouts.project_name.title"
- - "*.geocoder.search_osm_nominatim.*"
- - file: "app/assets/javascripts/i18n/embed.js"
- pretty_print: true
- only:
- - "*.javascripts.embed.*"
--- /dev/null
+embed_fallback_translations:
+ enabled: true
+export_files:
+ enabled: true
+ files:
+ - template: "i18n/templates/template.js.erb"
+ output: "app/assets/javascripts/i18n/%{base_name}.js"
+translations:
+ - file: "i18n/data/:locale.json"
+ patterns:
+ - "*.date.*"
+ - "*.time.*"
+ - "*.browse.start_rjs.*"
+ - "*.javascripts.*"
+ - "*.site.edit.*"
+ - "*.site.index.remote_failed"
+ - "*.site.sidebar.search_results"
+ - "*.diary_entries.edit.marker_text"
+ - "*.layouts.project_name.title"
+ - "*.geocoder.search_osm_nominatim.*"
+ - file: "i18n/data/embed.json"
+ patterns:
+ - "*.javascripts.embed.*"
end
Rails.configuration.after_initialize do
+ require "i18n-js/listen"
+
+ # This will only run in development.
+ I18nJS.listen
+
I18n.available_locales
end
--- /dev/null
+OSM.i18n.store(<%= JSON.pretty_generate(translations) %>);
"private": true,
"dependencies": {
"cal-heatmap": "^4.2.4",
+ "i18n-js": "^4.5.1",
"jquery-simulate": "^1.0.2",
"js-cookie": "^3.0.0",
"leaflet": "^1.8.0",
//= require leaflet/dist/leaflet-src
//= require leaflet.osm
//= require leaflet.map
-//= require i18n/translations
describe("OSM", function () {
describe(".apiUrl", function () {
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
+bignumber.js@*:
+ version "9.1.2"
+ resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c"
+ integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==
+
binary-search-bounds@^2.0.0:
version "2.0.5"
resolved "https://registry.yarnpkg.com/binary-search-bounds/-/binary-search-bounds-2.0.5.tgz#125e5bd399882f71e6660d4bf1186384e989fba7"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
+i18n-js@^4.5.1:
+ version "4.5.1"
+ resolved "https://registry.yarnpkg.com/i18n-js/-/i18n-js-4.5.1.tgz#12ea3d6333552ff75be0904ea50705f5a263d172"
+ integrity sha512-n7jojFj1WC0tztgr0I8jqTXuIlY1xNzXnC3mjKX/YjJhimdM+jXM8vOmn9d3xQFNC6qDHJ4ovhdrGXrRXLIGkA==
+ dependencies:
+ bignumber.js "*"
+ lodash "*"
+ make-plural "*"
+
iconv-lite@0.6:
version "0.6.3"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
-make-plural@^7.4.0:
+lodash@*:
+ version "4.17.21"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
+ integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
+
+make-plural@*, make-plural@^7.4.0:
version "7.4.0"
resolved "https://registry.yarnpkg.com/make-plural/-/make-plural-7.4.0.tgz#fa6990dd550dea4de6b20163f74e5ed83d8a8d6d"
integrity sha512-4/gC9KVNTV6pvYg2gFeQYTW3mWaoJt7WZE5vrp1KnQDgW92JtYZnzmZT81oj/dUTqAIu0ufI2x3dkgu3bB1tYg==