Skip to content

Commit c988c19

Browse files
committed
Fix translation path bug
1 parent c6ae6ba commit c988c19

8 files changed

Lines changed: 45 additions & 12 deletions

File tree

build/ableplayer.dist.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@
115115
if ($(media).data('root-path') !== undefined) {
116116
// remove trailing slashes if there are any
117117
this.rootPath = $(media).data('root-path').replace(/\/+$/, "");
118+
this.scriptPath = this.rootPath;
118119
}
119120
else {
120121
this.rootPath = this.getRootWebSitePath();
122+
this.scriptPath = this.getScriptPath();
121123
}
122124

123125
// Volume
@@ -461,6 +463,15 @@
461463
return webFolderFullPath;
462464
};
463465

466+
AblePlayer.prototype.getScriptPath = function() {
467+
468+
// returns path to Able Player JavaScript file
469+
var scripts= document.getElementsByTagName('script');
470+
var path= scripts[scripts.length-1].src.split('?')[0]; // remove any ?query
471+
var ableDir= path.split('/').slice(0, -1).join('/')+'/'; // remove last filename part of path
472+
return ableDir;
473+
};
474+
464475
AblePlayer.prototype.setIconColor = function() {
465476

466477
// determine the best color choice (white or black) for icons,
@@ -11925,7 +11936,6 @@
1192511936
};
1192611937

1192711938
AblePlayer.prototype.getTranslationText = function() {
11928-
1192911939
// determine language, then get labels and prompts from corresponding translation var
1193011940
var deferred, thisObj, lang, thisObj, msg, translationFile;
1193111941

@@ -11958,7 +11968,8 @@
1195811968
}
1195911969
}
1196011970

11961-
translationFile = '../translations/' + this.lang + '.js';
11971+
// this.scriptPath is location of AblePlayer JavaScript file (default: /build)
11972+
translationFile = this.scriptPath + '../translations/' + this.lang + '.js';
1196211973
this.importTranslationFile(translationFile).then(function(result) {
1196311974
thisObj.tt = eval(thisObj.lang);
1196411975
deferred.resolve();

build/ableplayer.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@
115115
if ($(media).data('root-path') !== undefined) {
116116
// remove trailing slashes if there are any
117117
this.rootPath = $(media).data('root-path').replace(/\/+$/, "");
118+
this.scriptPath = this.rootPath;
118119
}
119120
else {
120121
this.rootPath = this.getRootWebSitePath();
122+
this.scriptPath = this.getScriptPath();
121123
}
122124

123125
// Volume
@@ -461,6 +463,15 @@
461463
return webFolderFullPath;
462464
};
463465

466+
AblePlayer.prototype.getScriptPath = function() {
467+
468+
// returns path to Able Player JavaScript file
469+
var scripts= document.getElementsByTagName('script');
470+
var path= scripts[scripts.length-1].src.split('?')[0]; // remove any ?query
471+
var ableDir= path.split('/').slice(0, -1).join('/')+'/'; // remove last filename part of path
472+
return ableDir;
473+
};
474+
464475
AblePlayer.prototype.setIconColor = function() {
465476

466477
// determine the best color choice (white or black) for icons,
@@ -11925,7 +11936,6 @@
1192511936
};
1192611937

1192711938
AblePlayer.prototype.getTranslationText = function() {
11928-
1192911939
// determine language, then get labels and prompts from corresponding translation var
1193011940
var deferred, thisObj, lang, thisObj, msg, translationFile;
1193111941

@@ -11958,7 +11968,8 @@
1195811968
}
1195911969
}
1196011970

11961-
translationFile = '../translations/' + this.lang + '.js';
11971+
// this.scriptPath is location of AblePlayer JavaScript file (default: /build)
11972+
translationFile = this.scriptPath + '../translations/' + this.lang + '.js';
1196211973
this.importTranslationFile(translationFile).then(function(result) {
1196311974
thisObj.tt = eval(thisObj.lang);
1196411975
deferred.resolve();

build/ableplayer.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/ableplayer.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ableplayer",
3-
"version": "3.0.20",
3+
"version": "3.0.21",
44
"description": "fully accessible HTML5 media player",
55
"homepage": "http://ableplayer.github.io/ableplayer",
66
"bugs": "https://github.com/ableplayer/ableplayer/issues",

scripts/ableplayer-base.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@
115115
if ($(media).data('root-path') !== undefined) {
116116
// remove trailing slashes if there are any
117117
this.rootPath = $(media).data('root-path').replace(/\/+$/, "");
118+
this.scriptPath = this.rootPath;
118119
}
119120
else {
120121
this.rootPath = this.getRootWebSitePath();
122+
this.scriptPath = this.getScriptPath();
121123
}
122124

123125
// Volume

scripts/initialize.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020
return webFolderFullPath;
2121
};
2222

23+
AblePlayer.prototype.getScriptPath = function() {
24+
25+
// returns path to Able Player JavaScript file
26+
var scripts= document.getElementsByTagName('script');
27+
var path= scripts[scripts.length-1].src.split('?')[0]; // remove any ?query
28+
var ableDir= path.split('/').slice(0, -1).join('/')+'/'; // remove last filename part of path
29+
return ableDir;
30+
};
31+
2332
AblePlayer.prototype.setIconColor = function() {
2433

2534
// determine the best color choice (white or black) for icons,

scripts/translation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
};
88

99
AblePlayer.prototype.getTranslationText = function() {
10-
1110
// determine language, then get labels and prompts from corresponding translation var
1211
var deferred, thisObj, lang, thisObj, msg, translationFile;
1312

@@ -40,7 +39,8 @@
4039
}
4140
}
4241

43-
translationFile = '../translations/' + this.lang + '.js';
42+
// this.scriptPath is location of AblePlayer JavaScript file (default: /build)
43+
translationFile = this.scriptPath + '../translations/' + this.lang + '.js';
4444
this.importTranslationFile(translationFile).then(function(result) {
4545
thisObj.tt = eval(thisObj.lang);
4646
deferred.resolve();

0 commit comments

Comments
 (0)