Skip to content

Commit

Permalink
fix for #160 and #161
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Jackowski committed May 27, 2016
1 parent f4ddddc commit 3167535
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
11 changes: 10 additions & 1 deletion includes/lib/transifex-live-integration-javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Transifex_Live_Integration_Javascript {
*/
private $language_map;
private $url_options;
private $subdomain_pattern;

/**
* Public constructor, sets local settings
Expand All @@ -47,6 +48,7 @@ public function __construct( $settings, $live_settings ) {
$this->source_language = $settings['source_language'];
$this->language_map = $settings['language_map'];
$this->url_options = $settings['url_options'];
$this->subdomain_pattern = $settings['subdomain_pattern'];
}

/**
Expand Down Expand Up @@ -108,7 +110,14 @@ function wp_head_hook() {
$language_map .= "case '$value': return '$key'; break; ";
}
$snippet .= <<<SUBDOMAIN
<script type="text/javascript">function subdomain_detect_lang() {var a = window.location.host.split( '.' )[0]; switch(a) { $language_map case 'www': return true; break;} return a;}</script>
<script type="text/javascript">
function subdomain_detect_lang() {
var s = window.location.host;
var r = $subdomain_pattern;
var m = r.exec(s);
var a = m[1];
switch(a) { $language_map case 'www': return true; break;} return a;}
</script>
SUBDOMAIN;
$detectlang = "subdomain_detect_lang";
Expand Down
2 changes: 1 addition & 1 deletion includes/transifex-live-integration-defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static function settings() {
'languages' => '',
'hreflang' => false,
'url_options' => 1,
'subdomain_pattern' => '',
'subdomain_pattern' => '/(.*?)\.(?=[^\/]*\..{2,5})/i',
'static_frontpage_support' => false,
'enable_prerender' => 0,
'prerender_url' => '',
Expand Down
8 changes: 7 additions & 1 deletion javascript/transifex-live-integration-settings-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,24 @@ function transifex_live_integration_map_update(tl) {
} else {
var t = transifex_languages;
}
var h = [];
//var h = [];
var local_lm = [];
var local_hreflm = [];
var arr = {};
var arrr= {};
// loop through transifex languages
jQuery.each(
t, function (i, s) {
var l = jQuery('#transifex-integration-live-' + s).val();
var h = jQuery('#transifex-integration-live-hreflang-' + s).val();
arrr[s] = h;
arr[s] = l;
}
);
local_lm.push(arr);
local_hreflm.push(arrr);
jQuery('#transifex_live_settings_language_map').val(JSON.stringify(local_lm));
jQuery('#transifex_live_settings_hreflang_map').val(JSON.stringify(local_hreflm));
return true;
}

Expand Down

0 comments on commit 3167535

Please sign in to comment.