Skip to content

Commit

Permalink
Merge pull request #244 from BitBagCommerce/fix/translations
Browse files Browse the repository at this point in the history
Added translations for modal texts
  • Loading branch information
senghe committed Mar 11, 2024
2 parents bddbabf + fba1595 commit a2fb2da
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 26 deletions.
15 changes: 0 additions & 15 deletions features/assigning_wishlist_to_user.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,3 @@ Feature: Assigning a wishlist to a user
Then I should have 0 wishlists
And I should not see "Wishlist-assigned"

@ui @javascript
Scenario: Logout without assigning a wishlist to a user
Given the store has a product "Jack Daniels Gentleman" priced at "$10.00"
And all store products appear under a main taxonomy
And I add this product to wishlist
When I go to "/"
And I log in as "jdeer@sylius.pl"
And I go to "/wishlists"
And I press "wishlist-edit-button-Wishlist"
And I fill in "edit_wishlist_name" with "Wishlist-not-assigned"
And I press "edit_wishlist_save"
And I log out
And I go to "/wishlists"
Then I should have 1 wishlists
And I should see "Wishlist-not-assigned"
3 changes: 2 additions & 1 deletion src/Resources/assets/shop/js/copyToWishlistsListModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class CreateCopyToWishlistsListModal {
headerTitle: 'Choose a wishlist to which selected items should be copied',
cancelText: 'cancel',
performText: 'perform',
wishlistSelectionPlaceholder: 'My Wishlist…',
datasetWishlistTargets: '[data-bb-wishlists]',
datasetWishlistTargetsId: '[data-bb-wishlists-id]',
datasetWishlistCurrentId: '[data-bb-current-wishlist-id]',
Expand Down Expand Up @@ -86,7 +87,7 @@ export class CreateCopyToWishlistsListModal {
const select = document.createElement('select')
select.name = 'wishlist'
select.classList.add('ui', 'selection', 'dropdown')
select.insertAdjacentHTML("beforeend" ,'<option selected disabled>My Wishlist…</option>')
select.insertAdjacentHTML("beforeend" ,`<option selected disabled>${this.finalConfig.wishlistSelectionPlaceholder}</option>`)

this.wishlistTargets.forEach(wishlist => {
select.insertAdjacentHTML("beforeend" , this._wishlistTemplate(wishlist))
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/assets/shop/js/handleAddAnotherWishlistModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ const setWishlistModal = () => {
addWishlistBtn.addEventListener('click', () => {
new WishlistModal(
{
headerTitle: 'Choose name for your new wishlist',
headerTitle: document.querySelector("[data-bb-wishlist-add-title]").dataset.bbWishlistAddTitle,
cancelText: document.querySelector("[data-bb-wishlist-add-cancel]").dataset.bbWishlistAddCancel,
performText: document.querySelector("[data-bb-wishlist-add-perform]").dataset.bbWishlistAddPerform,
wishlistFormName: wishlistFormName,
wishlistBodyContent: `
<input type="text" id="${wishlistFormName}_name" name="${wishlistFormName}[name]" required="required" class="wishlist-confirmation-modal__body--input" data-bb-target="input" maxlength="50">
<div class="ui red pointing label validation-error hidden" data-bb-target="error">Please enter wishlist name.</div>
<div class="ui red pointing label validation-error hidden" data-bb-target="error">${document.querySelector("[data-bb-wishlist-add-error]").dataset.bbWishlistAddError}</div>
`
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ const setAddWishlistModal = () => {
e.preventDefault();

new CreateCopyToWishlistsListModal(
{},
{
headerTitle: document.querySelector("[data-bb-wl-list-modal-title]").dataset.bbWlListModalTitle,
cancelText: document.querySelector("[data-bb-wl-list-modal-cancel]").dataset.bbWlListModalCancel,
performText: document.querySelector("[data-bb-wl-list-modal-perform]").dataset.bbWlListModalPerform,
wishlistSelectionPlaceholder: document.querySelector("[data-bb-wl-list-modal-placeholder]").dataset.bbWlListModalPlaceholder,
},
{
cancelAction: () => {},
performAction: async () => {
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/assets/shop/js/handleEditWishlistModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ const setWishlistModal = () => {
btn.addEventListener('click', () => {
new WishlistModal(
{
headerTitle: 'Choose new name for your wishlist',
headerTitle: btn.dataset.wishlistEditTitle,
cancelText: btn.dataset.wishlistEditCancel,
performText: btn.dataset.wishlistEditPerform,
wishlistFormName: wishlistFormName,
wishlistBodyContent: `
<input type="text" id="${wishlistFormName}_name" name="${wishlistFormName}_name[name]" required="required" class="wishlist-confirmation-modal__body--input" data-bb-target="input" maxlength="50">
<div class="ui red pointing label validation-error hidden" data-bb-target="error">Please enter wishlist name.</div>
<div class="ui red pointing label validation-error hidden" data-bb-target="error">${btn.dataset.wishlistEditError}</div>
`
},
{
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/assets/shop/js/handleRemoveWishlistModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ const setWishlistModal = () => {
btn.addEventListener('click', () => {
new WishlistModal(
{
headerTitle: 'Remove wishlist',
headerTitle: btn.dataset.wishlistRemoveTitle,
wishlistFormName: wishlistFormName,
wishlistBodyContent: 'Are you sure?'
wishlistBodyContent: btn.dataset.wishlistRemoveContent,
performText: btn.dataset.wishlistRemovePerform,
cancelText: btn.dataset.wishlistRemoveCancel
},
{
cancelAction: () => {},
Expand Down
1 change: 1 addition & 0 deletions src/Resources/assets/shop/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import './handleEditWishlistModal';
import { WishlistVariantButton } from './WishlistVariantButton';
import { WishlistVariantPrice } from './WishlistVariantPrice';


const WishlistVariantElements = [...document.querySelectorAll('[data-bb-toggle="wishlist-variant"]')];
export const WishlistVariantButtonList = WishlistVariantElements.map(button => new WishlistVariantButton(button).init());

Expand Down
10 changes: 10 additions & 0 deletions src/Resources/assets/shop/js/wishlistModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class WishlistModal {
_modalActions(template) {
const cancelBtn = template.querySelector('[data-bb-action="cancel"]');
const confirmBtn = template.querySelector('[data-bb-action="perform"]');
const input = template.querySelector('[data-bb-target="wishlists"] > [data-bb-target="input"]');

cancelBtn.addEventListener('click', () => {
this.actions.cancelAction();
Expand All @@ -90,6 +91,15 @@ export class WishlistModal {
this.actions.performAction();
this._closeModal();
});

if (input) {
input.addEventListener("keypress", function(event) {
if (event.key === "Enter") {
event.preventDefault();
confirmBtn.click();
}
});
}
}

_isInputValid(template) {
Expand Down
16 changes: 16 additions & 0 deletions src/Resources/translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,19 @@ bitbag_sylius_wishlist_plugin:
wishlist_saved: Wishlist has been saved.
you_have_no_access_to_that_wishlist: You have no access to that wishlist.
wishlist_has_product_variant: '%productName% variant is already in wishlist.'
wishlist_modal_copy_title: 'Choose a wishlist to which selected items should be copied'
wishlist_modal_copy_cancel: 'cancel'
wishlist_modal_copy_perform: 'perform'
wishlist_modal_add_title: 'Choose name for your new wishlist'
wishlist_modal_add_perform: 'perform'
wishlist_modal_add_cancel: 'cancel'
wishlist_modal_add_error: 'Please enter wishlist name.'
wishlist_modal_edit_title: 'Choose new name for your wishlist'
wishlist_modal_edit_error: 'Please enter wishlist name.'
wishlist_modal_edit_perform: 'perform'
wishlist_modal_edit_cancel: 'cancel'
wishlist_modal_remove_title: 'Remove wishlist'
wishlist_modal_remove_content: 'Are you sure?'
wishlist_modal_remove_perform: 'perform'
wishlist_modal_remove_cancel: 'cancel'
wishlist_modal_placeholder: 'My wishlists...'
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
</div>
{% if wishlists|length > 1 %}
<div class="item wishlist-dropdown-menu__item">
<button type="button" class="ui green button wishlist-item--button" {{ sylius_test_html_attribute('wishlist-copy-to-wishlist') }} data-bb-wl-list-modal-target="choose-wishlist-button" >
<button type="button" class="ui green button wishlist-item--button" {{ sylius_test_html_attribute('wishlist-copy-to-wishlist') }}
data-bb-wl-list-modal-target="choose-wishlist-button"
data-bb-wl-list-modal-title="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_copy_title'|trans }}"
data-bb-wl-list-modal-perform="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_copy_perform'|trans }}"
data-bb-wl-list-modal-cancel="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_copy_cancel'|trans }}"
data-bb-wl-list-modal-placeholder="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_placeholder'|trans }}"
>
<i class="copy icon"></i>
{{ 'bitbag_sylius_wishlist_plugin.ui.copy_to_wishlist'|trans }}
</button>
Expand Down
9 changes: 8 additions & 1 deletion src/Resources/views/WishlistDetails/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
{% if wishlists|length > 1 %}
{% else %}
<div class="middle aligned column">
<button id="create_new_wishlist_button" class="ui right floated primary button" data-bb-wishlist-add="add-another-wishlist" data-bb-wishlist-add-url="{{ path('bitbag_sylius_wishlist_plugin_shop_locale_wishlist_create_new_wishlist') }}">
<button id="create_new_wishlist_button" class="ui right floated primary button"
data-bb-wishlist-add="add-another-wishlist"
data-bb-wishlist-add-url="{{ path('bitbag_sylius_wishlist_plugin_shop_locale_wishlist_create_new_wishlist') }}"
data-bb-wishlist-add-title="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_add_title'|trans }}"
data-bb-wishlist-add-perform="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_add_perform'|trans }}"
data-bb-wishlist-add-cancel="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_add_cancel'|trans }}"
data-bb-wishlist-add-error="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_add_error'|trans }}"
>
{{ 'bitbag_sylius_wishlist_plugin.ui.add_another_wishlist'|trans }}
</button>
<input type="hidden" data-bb-csrf="{{ csrf_token('some-name') }}"/>
Expand Down
15 changes: 14 additions & 1 deletion src/Resources/views/WishlistGroup/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
</div>
<div class="middle aligned column">
<button id="create_new_wishlist_button" class="ui right floated primary button" data-bb-wishlist-add="add-another-wishlist"
data-bb-wishlist-add="add-another-wishlist" data-bb-wishlist-add-url="{{ path('bitbag_sylius_wishlist_plugin_shop_locale_wishlist_create_new_wishlist') }}"
data-bb-wishlist-add="add-another-wishlist"
data-bb-wishlist-add-url="{{ path('bitbag_sylius_wishlist_plugin_shop_locale_wishlist_create_new_wishlist') }}"
data-bb-wishlist-add-title="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_add_title'|trans }}"
data-bb-wishlist-add-perform="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_add_perform'|trans }}"
data-bb-wishlist-add-cancel="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_add_cancel'|trans }}"
data-bb-wishlist-add-error="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_add_error'|trans }}"
>
{{ 'bitbag_sylius_wishlist_plugin.ui.add_another_wishlist'|trans }}
</button>
Expand Down Expand Up @@ -54,6 +59,10 @@
{{ sylius_test_html_attribute('wishlist-wishlist-remove') }}
data-wishlist-name="{{ wishlist.name }}"
data-wishlist-remove-id="{{ wishlist.id }}"
data-wishlist-remove-title="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_remove_title'|trans }}"
data-wishlist-remove-content="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_remove_content'|trans }}"
data-wishlist-remove-perform="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_remove_perform'|trans }}"
data-wishlist-remove-cancel="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_remove_cancel'|trans }}"
>
<i class="icon remove"></i>
</button>
Expand All @@ -62,6 +71,10 @@
{{ sylius_test_html_attribute('wishlist-wishlist-edit') }}
data-wishlist-name="{{ wishlist.name }}"
data-wishlist-edit-id="{{ wishlist.id }}"
data-wishlist-edit-title="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_edit_title'|trans }}"
data-wishlist-edit-error="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_edit_error'|trans }}"
data-wishlist-edit-perform="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_edit_perform'|trans }}"
data-wishlist-edit-cancel="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_edit_cancel'|trans }}"
>
<i class="icon edit"></i>
</button>
Expand Down

0 comments on commit a2fb2da

Please sign in to comment.