solidus_i18n 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +1 -1
- data/.travis.yml +10 -5
- data/Gemfile +3 -1
- data/app/assets/javascripts/spree/backend/edit_inline_locales.js.coffee.erb +56 -0
- data/app/assets/javascripts/spree/backend/helpers.js.coffee.erb +14 -0
- data/app/assets/javascripts/spree/backend/inline_table_locales.js.coffee +16 -0
- data/app/assets/javascripts/spree/backend/templates/available_locales.hbs.erb +31 -0
- data/app/assets/javascripts/spree/backend/translations.js.coffee +0 -2
- data/app/controllers/spree/api/available_locales_controller.rb +28 -0
- data/app/controllers/spree/locale_controller_decorator.rb +3 -4
- data/app/helpers/solidus_i18n/locale_helper.rb +8 -10
- data/app/models/spree/store_decorator.rb +13 -0
- data/app/overrides/spree/shared/_main_nav_bar/locale_selector.html.erb.deface +1 -1
- data/app/views/spree/admin/locales/show.html.erb +18 -24
- data/app/views/spree/api/available_locales/show.json.jbuilder +8 -0
- data/config/locales/bg.yml +0 -46
- data/config/locales/ca.yml +12 -45
- data/config/locales/cs.yml +0 -47
- data/config/locales/da.yml +0 -46
- data/config/locales/de-CH.yml +0 -44
- data/config/locales/de.yml +6 -48
- data/config/locales/en-AU.yml +0 -44
- data/config/locales/en-GB.yml +0 -46
- data/config/locales/en-IN.yml +1 -47
- data/config/locales/en-NZ.yml +0 -44
- data/config/locales/es-CL.yml +0 -48
- data/config/locales/es-EC.yml +0 -46
- data/config/locales/es-MX.yml +8 -49
- data/config/locales/es.yml +13 -59
- data/config/locales/et.yml +0 -46
- data/config/locales/fa.yml +0 -44
- data/config/locales/fi.yml +0 -46
- data/config/locales/fr.yml +656 -55
- data/config/locales/id.yml +1 -45
- data/config/locales/it.yml +0 -46
- data/config/locales/ja.yml +6 -52
- data/config/locales/ko.yml +0 -44
- data/config/locales/lv.yml +0 -44
- data/config/locales/nb.yml +0 -44
- data/config/locales/nl.yml +0 -46
- data/config/locales/pl.yml +0 -46
- data/config/locales/pt-BR.yml +1059 -237
- data/config/locales/pt.yml +0 -44
- data/config/locales/ro.yml +0 -46
- data/config/locales/ru.yml +0 -47
- data/config/locales/sk.yml +0 -44
- data/config/locales/sl-SI.yml +0 -44
- data/config/locales/sv.yml +0 -46
- data/config/locales/th.yml +0 -44
- data/config/locales/tr.yml +0 -44
- data/config/locales/uk.yml +0 -48
- data/config/locales/vi.yml +0 -44
- data/config/locales/zh-CN.yml +0 -44
- data/config/locales/zh-TW.yml +0 -44
- data/config/routes.rb +6 -0
- data/db/migrate/20170523151209_add_available_locales_on_store.rb +14 -0
- data/lib/solidus_i18n/controller_locale_helper.rb +1 -1
- data/lib/solidus_i18n/engine.rb +0 -1
- data/lib/solidus_i18n/locale.rb +3 -7
- data/lib/solidus_i18n/version.rb +1 -1
- data/solidus_i18n.gemspec +4 -3
- data/spec/controllers/locales_controller_spec.rb +2 -1
- data/spec/features/admin/translations_spec.rb +30 -8
- data/spec/features/translations_spec.rb +3 -1
- data/spec/helpers/locale_helper_spec.rb +35 -0
- data/spec/lib/solidus_i18n/locale_spec.rb +53 -0
- data/spec/support/capybara.rb +2 -7
- metadata +35 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0de9177ef69dd299f196ad557a46b1bae3bed9cae5e7895355564802330c04eb
|
4
|
+
data.tar.gz: 9e3f5ff6b46eb825e22b85797025cbd63c4cc2b0b6a7b689bd11f06333c16df2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d200695f22be7bbc14d2b0cab0c97b589024b0ece7595e18a8c8ea2759a14791d76013810dbd93394c2dee5e5f63de3d6a284f6a60c7dfc3f7da5dc177f26eb
|
7
|
+
data.tar.gz: fa2f1672afdeb8be73d6b4e414ffba0d6bf21b69e3341a9743479171c524dd160833b2a5d5f8125c646f1c1e8f597b1e19fb8f73cd67a591f01d63095e605a03
|
data/.hound.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
dist: trusty
|
2
|
+
sudo: required
|
3
|
+
addons:
|
4
|
+
chrome: stable
|
5
5
|
cache: bundler
|
6
6
|
language: ruby
|
7
|
+
before_install:
|
8
|
+
- gem update --system # https://github.com/travis-ci/travis-ci/issues/8978
|
9
|
+
- gem install bundler
|
7
10
|
rvm:
|
8
|
-
- 2.
|
11
|
+
- 2.5
|
9
12
|
env:
|
10
13
|
matrix:
|
11
14
|
- SOLIDUS_BRANCH=v1.1 DB=postgres
|
@@ -17,6 +20,7 @@ env:
|
|
17
20
|
- SOLIDUS_BRANCH=v2.2 DB=postgres
|
18
21
|
- SOLIDUS_BRANCH=v2.3 DB=postgres
|
19
22
|
- SOLIDUS_BRANCH=v2.4 DB=postgres
|
23
|
+
- SOLIDUS_BRANCH=v2.5 DB=postgres
|
20
24
|
- SOLIDUS_BRANCH=master DB=postgres
|
21
25
|
- SOLIDUS_BRANCH=v1.1 DB=mysql
|
22
26
|
- SOLIDUS_BRANCH=v1.2 DB=mysql
|
@@ -27,4 +31,5 @@ env:
|
|
27
31
|
- SOLIDUS_BRANCH=v2.2 DB=mysql
|
28
32
|
- SOLIDUS_BRANCH=v2.3 DB=mysql
|
29
33
|
- SOLIDUS_BRANCH=v2.4 DB=mysql
|
34
|
+
- SOLIDUS_BRANCH=v2.5 DB=mysql
|
30
35
|
- SOLIDUS_BRANCH=master DB=mysql
|
data/Gemfile
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
Spree.EditInlineLocales = Backbone.View.extend(
|
2
|
+
initialize: ->
|
3
|
+
@editing = false
|
4
|
+
@render()
|
5
|
+
|
6
|
+
events:
|
7
|
+
'click [data-action=edit]': 'onEdit'
|
8
|
+
'click [data-action=save]': 'onSave'
|
9
|
+
'click [data-action=cancel]': 'onCancel'
|
10
|
+
|
11
|
+
onEdit: (e) ->
|
12
|
+
return if @editing
|
13
|
+
@$el.addClass 'editing'
|
14
|
+
@editing = true
|
15
|
+
@render()
|
16
|
+
|
17
|
+
onCancel: (e) ->
|
18
|
+
e.preventDefault()
|
19
|
+
@$el.removeClass("editing")
|
20
|
+
@editing = false
|
21
|
+
@render()
|
22
|
+
|
23
|
+
onSave: (e) ->
|
24
|
+
e.preventDefault()
|
25
|
+
preferred_available_locales = $('#available-locales-store-' + @model.id)
|
26
|
+
Spree.ajax
|
27
|
+
type: 'PUT'
|
28
|
+
url: Spree.routes.available_locales_api + '/' + @model.id + '.json'
|
29
|
+
data:
|
30
|
+
store:
|
31
|
+
preferred_available_locales: preferred_available_locales.val()
|
32
|
+
success: (response) =>
|
33
|
+
@model = response.store
|
34
|
+
@editing = false
|
35
|
+
@$el.removeClass("editing")
|
36
|
+
@render()
|
37
|
+
error: (response) =>
|
38
|
+
show_flash 'error', response.responseJSON.error
|
39
|
+
|
40
|
+
render: ->
|
41
|
+
renderAttr =
|
42
|
+
availableLocales: <%= SolidusI18n::Locale.all.push(:en).to_json %>
|
43
|
+
availableLocalesPresentation: <%= Hash[(SolidusI18n::Locale.all + [:en]).map do |locale|
|
44
|
+
[locale, Spree.t(:'i18n.this_file_language', locale: locale)]
|
45
|
+
end].to_json %>
|
46
|
+
store: @model
|
47
|
+
editing: @editing
|
48
|
+
_.extend(renderAttr, @model.attributes)
|
49
|
+
|
50
|
+
@$el.html(HandlebarsTemplates['available_locales'](renderAttr))
|
51
|
+
$('.available-locales').select2({placeholder: Spree.translations['please_choose_language'], width: 'element'})
|
52
|
+
|
53
|
+
return @
|
54
|
+
)
|
55
|
+
|
56
|
+
Spree.routes.available_locales_api = Spree.pathFor('api/config/available_locales');
|
@@ -0,0 +1,14 @@
|
|
1
|
+
window.Handlebars.registerHelper 'locale-presentation', (locale, localePresentationHashmap, options) ->
|
2
|
+
localePresentationHashmap[locale]
|
3
|
+
|
4
|
+
window.Handlebars.registerHelper 'selected', (locale, store, options) ->
|
5
|
+
for k of store.preferences.available_locales
|
6
|
+
value = store.preferences.available_locales[k]
|
7
|
+
return 'selected="selected"' if value == locale
|
8
|
+
|
9
|
+
window.Handlebars.registerHelper 'store-available-locales', (store, options) ->
|
10
|
+
locales = for k of store.preferences.available_locales
|
11
|
+
locale = store.preferences.available_locales[k]
|
12
|
+
@availableLocalesPresentation[locale]
|
13
|
+
|
14
|
+
locales.join(',')
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Spree.InlineTableLocales = Backbone.View.extend(
|
2
|
+
initialize: ->
|
3
|
+
if @$el.length
|
4
|
+
Spree.ajax({
|
5
|
+
type: 'GET'
|
6
|
+
url: "/api/config/available_locales"
|
7
|
+
success: (collection) =>
|
8
|
+
for store in collection
|
9
|
+
row = $("<tr id='store-id-#{store.id}'/>")
|
10
|
+
@$el.append(row)
|
11
|
+
new Spree.EditInlineLocales({
|
12
|
+
el: row
|
13
|
+
model: store
|
14
|
+
});
|
15
|
+
})
|
16
|
+
)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<td>
|
2
|
+
{{store.name}}
|
3
|
+
{{#if store.default}}
|
4
|
+
<span class="label label-default">default</span>
|
5
|
+
{{/if}}
|
6
|
+
</td>
|
7
|
+
<td>{{store.url}}</td>
|
8
|
+
<td>
|
9
|
+
{{#if editing}}
|
10
|
+
<select id='available-locales-store-{{store.id}}' class='available-locales select2 fullwidth' name='store[preferred_available_locales][]' multiple='true'>
|
11
|
+
{{#each availableLocales}}
|
12
|
+
<option value="{{ this }}" {{#selected this ../store}}{{/selected}}>
|
13
|
+
{{#locale-presentation this ../availableLocalesPresentation}}{{/locale-presentation}}
|
14
|
+
</option>
|
15
|
+
{{/each}}
|
16
|
+
</select>
|
17
|
+
{{else}}
|
18
|
+
{{store-available-locales store availableLocales}}
|
19
|
+
{{#each store.preferences.available_locales}}
|
20
|
+
{{locale-presentation this}}
|
21
|
+
{{/each}}
|
22
|
+
{{/if}}
|
23
|
+
</td>
|
24
|
+
<td class="actions">
|
25
|
+
{{#if editing}}
|
26
|
+
<a class="fa fa-check icon_link with-tip no-text" data-action="save" data-id="{{id}}" href="#"></a>
|
27
|
+
<a class="fa fa-cancel icon_link with-tip no-text" data-action="cancel" data-id="{{id}}" href="#"></a>
|
28
|
+
{{else}}
|
29
|
+
<a class="fa fa-edit icon_link with-tip no-text" data-action="edit" data-id="{{id}}" href="#"></a>
|
30
|
+
{{/if}}
|
31
|
+
</td>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
class AvailableLocalesController < Spree::Api::BaseController
|
4
|
+
def index
|
5
|
+
respond_with Store.all
|
6
|
+
end
|
7
|
+
|
8
|
+
def update
|
9
|
+
authorize! :update, store
|
10
|
+
if store.update_attributes(store_params)
|
11
|
+
respond_with(store, status: 200, default_template: :show)
|
12
|
+
else
|
13
|
+
invalid_resource!(store)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def store_params
|
20
|
+
params.require(:store).permit(preferred_available_locales: [])
|
21
|
+
end
|
22
|
+
|
23
|
+
def store
|
24
|
+
@store ||= Store.find(params[:id])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,21 +1,19 @@
|
|
1
1
|
module SolidusI18n
|
2
2
|
module LocaleHelper
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
def select_available_locales(store = nil)
|
4
|
+
select_tag('store[preferred_available_locales][]',
|
5
|
+
options_for_select(
|
6
|
+
all_locales_options,
|
7
|
+
store.preferred_available_locales
|
8
|
+
), common_options)
|
9
9
|
end
|
10
10
|
|
11
11
|
def available_locales_options
|
12
|
-
|
12
|
+
current_store.preferred_available_locales.map { |locale| locale_presentation(locale) }
|
13
13
|
end
|
14
14
|
|
15
|
-
# Need to manually add en to the array because the en.yml was moved from
|
16
|
-
# this project. solidusio/solidus now has those keys.
|
17
15
|
def all_locales_options
|
18
|
-
SolidusI18n::Locale.all.map { |locale| locale_presentation(locale) }
|
16
|
+
SolidusI18n::Locale.all.map { |locale| locale_presentation(locale) }
|
19
17
|
end
|
20
18
|
|
21
19
|
private
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module SolidusI18n
|
2
|
+
module AddAvailableLanguagesPreferenceToStore
|
3
|
+
def self.prepended(base)
|
4
|
+
base.preference :available_locales, :array, default: [:en]
|
5
|
+
end
|
6
|
+
|
7
|
+
def preferred_available_locales
|
8
|
+
super.map(&:to_sym)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Spree::Store.prepend AddAvailableLanguagesPreferenceToStore
|
13
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<!-- insert_bottom '#main-nav-bar' -->
|
2
|
-
<% if
|
2
|
+
<% if current_store.preferred_available_locales.many? %>
|
3
3
|
<li id="locale-select" data-hook>
|
4
4
|
<%= form_tag spree.set_locale_path, class: 'navbar-form' do %>
|
5
5
|
<div class="form-group">
|
@@ -1,27 +1,21 @@
|
|
1
1
|
<%= render 'spree/admin/shared/configuration_menu' %>
|
2
2
|
|
3
|
-
|
4
|
-
<
|
5
|
-
<
|
6
|
-
<
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
<table class="index locales-settings">
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<th><%= Spree::Store.human_attribute_name(:name) %></th>
|
7
|
+
<th><%= Spree::Store.human_attribute_name(:url) %></th>
|
8
|
+
<th><%= Spree.t(:'i18n.locales_displayed_on_frontend_select_box') %></th>
|
9
|
+
<th class="actions"></th>
|
10
|
+
</tr>
|
11
|
+
</thead>
|
12
|
+
<tbody>
|
13
|
+
<%# Rendered by JS %>
|
14
|
+
</tbody>
|
15
|
+
</table>
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<%= select_available_locales %>
|
17
|
-
<p class="help-block">
|
18
|
-
<%= Spree.t(:'i18n.locales_displayed_on_frontend_select_box') %>
|
19
|
-
</p>
|
20
|
-
</div>
|
21
|
-
</div>
|
22
|
-
</div>
|
23
|
-
|
24
|
-
<div class="form-buttons filter-actions actions" data-hook="buttons">
|
25
|
-
<%= button Spree.t('actions.update') %>
|
26
|
-
</div>
|
27
|
-
<% end %>
|
17
|
+
<script>
|
18
|
+
Spree.ready(function(){
|
19
|
+
new Spree.InlineTableLocales({ el: $("table.locales-settings > tbody") });
|
20
|
+
})
|
21
|
+
</script>
|
data/config/locales/bg.yml
CHANGED
@@ -275,52 +275,6 @@ bg:
|
|
275
275
|
spree/zone:
|
276
276
|
one: Zone Зона
|
277
277
|
other: "Зони"
|
278
|
-
devise:
|
279
|
-
confirmations:
|
280
|
-
confirmed: "Вашият акаунт е потвърден. Вече сте вписан."
|
281
|
-
send_instructions: "До няколко минути ще получите съобщение с обяснение как да потвърдите своя акаунт."
|
282
|
-
failure:
|
283
|
-
inactive: "Вашият акаунт все още не е активен."
|
284
|
-
invalid: "Грешен имейл или парола"
|
285
|
-
invalid_token: Invalid authentication token.
|
286
|
-
locked: "Вашият акаунт е заключен."
|
287
|
-
timeout: "Вашата сесия е изтекла, моля влезте повторно."
|
288
|
-
unauthenticated: "Трябва да се впишете или регистрирате преди да продължите"
|
289
|
-
unconfirmed: "Трябва да потвърдите акаунта си преди да продължите."
|
290
|
-
mailer:
|
291
|
-
confirmation_instructions:
|
292
|
-
subject: "Инструкции за потвърждаване"
|
293
|
-
reset_password_instructions:
|
294
|
-
subject: Reset password instructions Инструкции за смяна на паролата
|
295
|
-
unlock_instructions:
|
296
|
-
subject: "Инструкции за отключване"
|
297
|
-
oauth_callbacks:
|
298
|
-
failure: Could not authorise you from %{kind} because %{reason}.
|
299
|
-
success: Successfully authorised from %{kind} account.
|
300
|
-
unlocks:
|
301
|
-
send_instructions: "До няколко минути ще получите имейл с инструкции как да отключите своя акаунт."
|
302
|
-
unlocked: "Вашият акаунт бе отключен успешно. Вече сте вписани."
|
303
|
-
user_passwords:
|
304
|
-
user:
|
305
|
-
cannot_be_blank: "Вашата парола не може бъде празна"
|
306
|
-
send_instructions: "До няколко минути ще получите имейл с инструкции как да промените паролата си."
|
307
|
-
updated: "Вашата парола бе променена успешко. Вече сте вписани."
|
308
|
-
user_registrations:
|
309
|
-
destroyed: "Вашият акаунт бе отменен успешно. Надяваме се да ви видим скоро."
|
310
|
-
inactive_signed_up: You have signed up successfully. However, we could not sign you in because your account is %{reason}.
|
311
|
-
signed_up: "Вие се регистрирахте успешно."
|
312
|
-
updated: "Успешно обновихте своя акаунт."
|
313
|
-
user_sessions:
|
314
|
-
signed_in: "Успешно влизане"
|
315
|
-
signed_out: "Успешно излизане"
|
316
|
-
errors:
|
317
|
-
messages:
|
318
|
-
already_confirmed: "Вече бе потвърден"
|
319
|
-
not_found: "не намерен"
|
320
|
-
not_locked: "не бе заключен"
|
321
|
-
not_saved:
|
322
|
-
one: "Една грешка предоотврати запазването на %{resource}"
|
323
|
-
other: "%{count} грешки предоотвратиха запазването на %{resource}"
|
324
278
|
spree:
|
325
279
|
abbreviation: "Абривиатура"
|
326
280
|
accept:
|
data/config/locales/ca.yml
CHANGED
@@ -281,50 +281,6 @@ ca:
|
|
281
281
|
spree/zone:
|
282
282
|
one: Zona
|
283
283
|
other:
|
284
|
-
devise:
|
285
|
-
confirmations:
|
286
|
-
confirmed:
|
287
|
-
send_instructions:
|
288
|
-
failure:
|
289
|
-
inactive: El seu compte no s'ha estat activat encara.
|
290
|
-
invalid: Correu electrònic o contrasenya no vàlids.
|
291
|
-
invalid_token: Token d'autenticació no vàlid.
|
292
|
-
locked: El seu compte està bloquejat.
|
293
|
-
timeout:
|
294
|
-
unauthenticated:
|
295
|
-
unconfirmed:
|
296
|
-
mailer:
|
297
|
-
confirmation_instructions:
|
298
|
-
subject:
|
299
|
-
reset_password_instructions:
|
300
|
-
subject:
|
301
|
-
unlock_instructions:
|
302
|
-
subject:
|
303
|
-
oauth_callbacks:
|
304
|
-
failure:
|
305
|
-
success:
|
306
|
-
unlocks:
|
307
|
-
send_instructions:
|
308
|
-
unlocked:
|
309
|
-
user_passwords:
|
310
|
-
user:
|
311
|
-
cannot_be_blank:
|
312
|
-
send_instructions:
|
313
|
-
updated:
|
314
|
-
user_registrations:
|
315
|
-
destroyed:
|
316
|
-
inactive_signed_up:
|
317
|
-
signed_up:
|
318
|
-
updated:
|
319
|
-
user_sessions:
|
320
|
-
signed_in:
|
321
|
-
signed_out:
|
322
|
-
errors:
|
323
|
-
messages:
|
324
|
-
already_confirmed:
|
325
|
-
not_found: no trobat
|
326
|
-
not_locked:
|
327
|
-
not_saved:
|
328
284
|
spree:
|
329
285
|
abbreviation: Abreviatura
|
330
286
|
accept:
|
@@ -1027,7 +983,18 @@ ca:
|
|
1027
983
|
receive: rebre
|
1028
984
|
receive_stock:
|
1029
985
|
received: Rebut
|
1030
|
-
|
986
|
+
reception_states:
|
987
|
+
awaiting: En espera
|
988
|
+
cancelled: Cancel·lat
|
989
|
+
expired: Expirat
|
990
|
+
given_to_customer: Entregat al client
|
991
|
+
in_transit: En trànsit
|
992
|
+
lost_in_transit: Perdut en trànsit
|
993
|
+
received: Rebut
|
994
|
+
shipped_wrong_item: Article incorrecte
|
995
|
+
short_shipped: No inclòs en l'enviament
|
996
|
+
unexchanged: Sense canvis
|
997
|
+
reception_status: Estat de recepció
|
1031
998
|
reference:
|
1032
999
|
refund: Retornar
|
1033
1000
|
refund_amount_must_be_greater_than_zero:
|