snipcart / snipcart-localization-v2

Localization files for Snipcart's shopping cart v2
https://docs.snipcart.com/v2/configuration/localization
MIT License
30 stars 114 forks source link

Irrelevant Debug Message : messages not reflect what is actually done. #54

Closed MachinisteWeb closed 7 years ago

MachinisteWeb commented 7 years ago

We plan to use Snipcart and currently, we try it. But it's appear the debug messages are not relevant. We need a strong debug message system during development phase to be able to do the maximum things without help. So, maybe is just a lack in documentation or me which is not implement my test in a correct way. This is my problem :

Disable messages

I have already read some closed issue and I know there is a way to disable debug message like this :

<script>
  document.addEventListener('snipcart.ready', function() {
    Snipcart.DEBUG = false;
  });
</script>

My curious behavior

It's seems some debug messages not reflect what is actually done.

Below, this is my started implementation:

<!DOCTYPE html>
<html lang="fr-fr" class="min">
    <head>
        <!-- meta -->

        <link href="https://cdn.snipcart.com/themes/2.0/base/snipcart.min.css" type="text/css" rel="stylesheet" />
    </head>
    <body>
        <!-- content -->

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
        <script src="https://cdn.snipcart.com/scripts/2.0/snipcart.js" id="snipcart" data-api-key="NzJhNzMwMWEtMjQwMi00Y2Q0LWI0YmUtNTRkMzg4OTBmYWU1NjM2MzY4MjI5NTI5MzcxMjY4" data-autopop="false"></script>
        <script type="text/javascript" src="scripts/fr-FR.js"></script>
    </body>
</html>

All files provide a 200 status message and scripts/fr-FR.js contain your current repository locales/fr-FR.js file.

So currently my console show me this.

Snipcart:  Locale fr not found, falling back to en
snipcart.js:8 Snipcart:  Missing localization string bill_me_later_action for locale fr
snipcart.js:8 Snipcart:  Missing localization string pay_via_mollie for locale fr
snipcart.js:8 Snipcart:  Missing localization string pay_now_via_mollie for locale fr
snipcart.js:8 Snipcart:  Missing localization string pay_via_mollie_explanation for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_status for locale fr
snipcart.js:8 Snipcart:  Missing localization string errors_passwords_dont_match for locale fr
snipcart.js:8 Snipcart:  Missing localization string error_discounts_have_expired for locale fr
snipcart.js:8 Snipcart:  Missing localization string subscriptions_history_no_subscriptions for locale fr
snipcart.js:8 Snipcart:  Missing localization string subscription_pause_button for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_failed_text for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_willbepaidlater for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_paypal for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_none for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_sofort for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_ideal for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_mistercash for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_banktransfer for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_directdebit for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_belfius for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_bitcoin for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_podiumcadeaukaart for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_paysafecard for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_bancontact for locale fr
snipcart.js:8 Snipcart:  Missing localization string payment_method_creditcard for locale fr
snipcart.js:8 Snipcart:  Missing localization string error_item_stock_exceeded for locale fr
snipcart.js:8 Snipcart:  Missing localization string error_item_out_of_stock_text for locale fr
snipcart.js:8 Snipcart:  Missing localization string item_out_of_stock_with_variant for locale fr
snipcart.js:8 Snipcart:  Missing localization string something_went_wrong_while_fetching_rates for locale fr
snipcart.js:8 Snipcart:  Missing localization string error_must_select_shipping_rate for locale fr
snipcart.js:8 Snipcart:  Missing localization string manage_subscriptions for locale fr
snipcart.js:8 Snipcart:  Missing localization string back_to_subscriptions_list for locale fr
snipcart.js:8 Snipcart:  Missing localization string back_to_subscription_details for locale fr
snipcart.js:8 Snipcart:  Missing localization string notifications_item_not_modified_due_to_min_quantity for locale fr
snipcart.js:8 Snipcart:  Missing localization string subscription_resume_buttom for locale fr
snipcart.js:8 Snipcart:  Missing localization string subscription_summary for locale fr
snipcart.js:8 Snipcart:  Missing localization string subscription_notifications_paused for locale fr
snipcart.js:8 Snipcart:  Missing localization string subscription_notifications_pause_confirm for locale fr
snipcart.js:8 Snipcart:  Missing localization string subscription_notifications_resume_confirm for locale fr
snipcart.js:8 Snipcart:  Missing localization string subscription_status_canceled for locale fr
snipcart.js:8 Snipcart:  Missing localization string subscription_status_paused for locale fr

Try to add the label

I have translated all labels not provided from fr-FR.js and I provide it in this PR : https://github.com/snipcart/snipcart-localization/pull/53

What I expected to see was this :

Snipcart:  Locale fr not found, falling back to en

but console show all messages.

Try to wait service API is ok

I had this code to wait the API is loading...

Snipcart.execute('app.ready', function () {
    Snipcart.execute('registerLocale', 'fr-FR', {
            ...
    });
});

What I expected to see was no messages anymore.

but console show all messages with this additional message:

...
Snipcart:  Command app.ready not recognized

Hurray ! It's seems debug message work a little bit...

Try to wait service API with the correct code...

Snipcart.execute('bind', 'app.ready', function () {
    Snipcart.execute('registerLocale', 'fr-FR', {
            ...
    });
});

Using this alternative code the previous Snipcart: Command app.ready not recognized is not display animore.

So what I expected is to see no error message anymore and all messages are always displayed.

Bug OR bad documentation explaination

So currently, your error message are not correct because the first message is

Snipcart:  Locale fr not found, falling back to en

And — I try to load fr-FR (not some fr) — My app is currently in French exactly as I expected. So it's just the debug message was not relevant.

Then, the rest of message are not correct either because my file is up-to-date : https://github.com/snipcart/snipcart-localization/pull/53

Test it

You can test that to go at https://blog.lesieur.name/espace-membres/. Just open console with F12 and see the not relevant message. Test to open interface to see it in french.

What I'm doing wrong ?

Thanks !

Jehu commented 7 years ago

I've the same problem here. Even Snipcart.DEBUG = false does not work.

JeanSebTr commented 7 years ago

Hi there!

Snipcart.DEBUG = false do effectively work, but some logs are written before Snipcart has completed its initialization. So by disabling the logs in :

document.addEventListener('snipcart.ready', function() {
    Snipcart.DEBUG = false;
});

the notices for missing translation are shown because the language is loaded before Snipcart is fully initialized. It is that way so that people can override specific sentences locally.

The log message Missing localization string {key name} for locale fr means that a French translation is not defined for that key.

And :

Snipcart.execute('app.ready', function () { /* ... */ });
// must be replace with
Snipcart.execute('bind', 'app.ready', function () { /* ... */ });

You are right that the message Snipcart: Locale fr not found, falling back to en should not show up. I'll open an issue about it, but being only a message in the dev logs it might not be prioritized very high.

MachinisteWeb commented 7 years ago

After testing this day, only remain the :

Snipcart: Locale fr not found, falling back to en

messages. All others are removed.

Thx.