getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.41k stars 1.4k forks source link

Javascript error when locale = 'no' #1872

Open achwell opened 6 years ago

achwell commented 6 years ago

When edit page:

vendor.min.js?68fa41ea5c:41 Uncaught TypeError: locale() locale no is not loaded from moment locales! at Object.c.locale (vendor.min.js?68fa41ea5c:41) at String. (vendor.min.js?68fa41ea5c:41) at Function.each (jquery-3.x.min.js?68fa41ea5c:2) at Object.c.options (vendor.min.js?68fa41ea5c:41) at n (vendor.min.js?68fa41ea5c:42) at HTMLInputElement. (vendor.min.js?68fa41ea5c:42) at Function.each (jquery-3.x.min.js?68fa41ea5c:2) at r.fn.init.each (jquery-3.x.min.js?68fa41ea5c:2) at r.fn.init.e.fn.datetimepicker (vendor.min.js?68fa41ea5c:42) at e.value (admin.min.js?68fa41ea5c:13)

When using norwegian locale 'no'. Could be fixed by a change in user\plugins\admin\themes\grav\js\vendor.min.js

from

c.locale=function(e){if(0===arguments.length) return i.locale;

to

c.locale=function(e){if(0===arguments.length) if(i.locale==='no') i.locale='nb'; return i.locale;

rhukster commented 6 years ago

I'm unable to replicate this so I need more information about what setup you have. Do you simply have one language specified and it's "no" ?

achwell commented 6 years ago

Only defined language is "no". "no" is default locale for Norway, but "nb" and "nn" are also Norwegian variants.

My user/config/system.yaml is like this:

absolute_urls: false timezone: Europe/Oslo default_locale: 'no' param_sep: ':' wrapped_site: false reverse_proxy_setup: false force_ssl: false force_lowercase_urls: true usernameregex: '^[a-z0-9-]{3,16}$' pwd_regex: '(?=.\d)(?=.[a-z])(?=.*[A-Z]).{8,}' intl_enabled: true languages: supported:

simenbw commented 6 years ago

I also experience the same issue. I have "en" and "no" language enabled and for each datepicker in grav admin i get javascript error: Uncaught TypeError: locale() locale no is not loaded from moment locales!

Stacktrace:

vendor.min.js?09275b16ed:40 Uncaught TypeError: locale() locale no is not loaded from moment locales!
    at Object.c.locale (vendor.min.js?09275b16ed:40)
    at String.<anonymous> (vendor.min.js?09275b16ed:40)
    at Function.each (jquery-2.x.min.js?09275b16ed:2)
    at Object.c.options (vendor.min.js?09275b16ed:40)
    at n (vendor.min.js?09275b16ed:41)
    at HTMLInputElement.<anonymous> (vendor.min.js?09275b16ed:41)
    at Function.each (jquery-2.x.min.js?09275b16ed:2)
    at n.fn.init.each (jquery-2.x.min.js?09275b16ed:2)
    at n.fn.init.e.fn.datetimepicker (vendor.min.js?09275b16ed:41)
    at e.value (admin.min.js?09275b16ed:13)
c.locale @ vendor.min.js?09275b16ed:40
(anonymous) @ vendor.min.js?09275b16ed:40
each @ jquery-2.x.min.js?09275b16ed:2
c.options @ vendor.min.js?09275b16ed:40
n @ vendor.min.js?09275b16ed:41
(anonymous) @ vendor.min.js?09275b16ed:41
each @ jquery-2.x.min.js?09275b16ed:2
each @ jquery-2.x.min.js?09275b16ed:2
e.fn.datetimepicker @ vendor.min.js?09275b16ed:41
value @ admin.min.js?09275b16ed:13
(anonymous) @ admin.min.js?09275b16ed:13
each @ jquery-2.x.min.js?09275b16ed:2
each @ jquery-2.x.min.js?09275b16ed:2
e @ admin.min.js?09275b16ed:13
(anonymous) @ admin.min.js?09275b16ed:13
t @ vendor.min.js?09275b16ed:1
(anonymous) @ admin.min.js?09275b16ed:12
t @ vendor.min.js?09275b16ed:1
(anonymous) @ admin.min.js?09275b16ed:10
t @ vendor.min.js?09275b16ed:1
(anonymous) @ admin.min.js?09275b16ed:1
(anonymous) @ admin.min.js?09275b16ed:1
t @ vendor.min.js?09275b16ed:1
window.webpackJsonpGrav @ vendor.min.js?09275b16ed:1
(anonymous) @ admin.min.js?09275b16ed:1
achwell commented 6 years ago

Maybe this issue should be in grav-plugin-admin?

OleVik commented 6 years ago

Probably, but anything else using Moment.js should take note: nb (Norwegian bokmål) is the correct locale-string, per their repo. There is no no available, only nb or nn (Norwegian nynorsk).

Admin really shouldn't be using no, the language file is unquestionably nb.