Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globalize urls when adding them via wymeditor #2533

Merged
merged 3 commits into from
Jan 28, 2014

Conversation

DanBrooker
Copy link
Contributor

When adding a link for a translated page via wymeditor, the link wasn't be localised.
This pull request localises URLs based on the locale of the translation.

Also updates the regex for switch_locale to match hyphenated language code, e.g. zh-CN or pt-BR

@@ -630,7 +630,7 @@ WYMeditor.editor.prototype.dialog = function( dialogType ) {
var wym = this;

wym.update();
var path = this._wym._options.dialogPath + dialogType + '?wymeditor=true&' + window.location.href.match(/switch_locale=[a-z]{2}/);
var path = this._wym._options.dialogPath + dialogType + '?wymeditor=true&' + window.location.href.match(/switch_locale=[a-z]{2}(-[A-Z]{2})?/)[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails with Uncaught TypeError: Cannot read property '0' of null when there's no switch_locale param available (in the case when we start editing page for the first time).

@DanBrooker
Copy link
Contributor Author

I've changed the regex so there's only one element in the array and therefore no need to access the first element.

ugisozols added a commit that referenced this pull request Jan 28, 2014
Globalize urls when adding them via wymeditor
@ugisozols ugisozols merged commit 72d8f80 into refinery:2-1-stable Jan 28, 2014
@ugisozols
Copy link
Member

Thanks @DanBrooker!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants