Merge pull request #15523 from nextcloud/refactor/oc-add-translations-bundle-deprecate

Move OC.addTranslations to the bundle and deprecate it
This commit is contained in:
Christoph Wurst 2019-05-14 10:04:51 +02:00 committed by GitHub
commit c2177caf52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 18 deletions

View File

@ -117,7 +117,7 @@ function se(e){for(var t,n=[],a=0,r=-1,i=0;a<e.length;){t=e.charAt(a);var s=!i&&
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/if(void 0===ue){var le=(ue=location.pathname).indexOf("/index.php/");ue=-1!==le?ue.substr(0,le):ue.substr(0,ue.lastIndexOf("/"))}var ce,_e=ue,me=a.a={coreApps:j.i,menuSpeed:j.j,PERMISSION_ALL:j.a,PERMISSION_CREATE:j.b,PERMISSION_DELETE:j.c,PERMISSION_NONE:j.d,PERMISSION_READ:j.e,PERMISSION_SHARE:j.f,PERMISSION_UPDATE:j.g,TAG_FAVORITE:j.h,addScript:function(e,t,n){var a;console.warn("OC.addScript is deprecated, use OCP.Loader.loadScript instead");var r=OC.filePath(e,"js",t+".js");return o[r]?n&&n():(a=s.a.Deferred(),s.a.getScript(r,function(){return a.resolve()}),o[r]=a),o[r]},addStyle:function(e,t){console.warn("OC.addStyle is deprecated, use OCP.Loader.loadStylesheet instead");var n=OC.filePath(e,"css",t+".css");-1===d.indexOf(n)&&(d.push(n),document.createStyleSheet?document.createStyleSheet(n):(t=s()('<link rel="stylesheet" type="text/css" href="'+n+'"/>'),s()("head").append(t)))},Apps:u.a,AppConfig:_,appConfig:c,appswebroots:m,Backbone:b,ContactsMenu:P.a,config:H,currentUser:E,dialogs:W,EventSource:I,getCurrentUser:function(){return{uid:E,displayName:O}},isUserAdmin:function(){return q},L10N:K,_capabilities:$(),getCapabilities:$,hideMenus:U,registerMenu:function(e,t,n,a){t.addClass("menu"),e.on("A"===e.prop("tagName")?"click.menu":"click.menu keyup.menu",function(r){r.preventDefault(),r.key&&"Enter"!==r.key||(t.is(J)?U():(J&&U(),!0===a&&t.parent().addClass("openedMenu"),e.attr("aria-expanded",!0),t.slideToggle(j.j,n),J=t,e))})},showMenu:function(e,t,n){t.is(J)||(U(),J=t,e,t.trigger(new s.a.Event("beforeShow")),t.show(),t.trigger(new s.a.Event("afterShow")),y.a.isFunction(n)&&n())},unregisterMenu:function(e,t){t.is(J)&&U(),e.off("click.menu").removeClass("menutoggle"),t.removeClass("menu")},basename:function(e){return e.replace(/\\/g,"/").replace(/.*\//,"")},encodePath:function(e){if(!e)return e;for(var t=e.split("/"),n=[],a=0;a<t.length;a++)n.push(encodeURIComponent(t[a]));return n.join("/")},dirname:function(e){return e.replace(/\\/g,"/").replace(/\/[^\/]*$/,"")},isSamePath:function(e,t){var n=(e||"").split("/").filter(function(e){return"."!==e}),a=(t||"").split("/").filter(function(e){return"."!==e});return(e=S.apply(void 0,n))===(t=S.apply(void 0,a))},joinPaths:S,getHost:function(){return window.location.host},getHostName:function(){return window.location.hostname},getPort:function(){return window.location.port},getProtocol:function(){return window.location.protocol.split(":")[0]},getCanonicalLocale:function(){var e=X();return"string"==typeof e?e.replace(/_/g,"-"):e},getLocale:X,getLanguage:function(){return s()("html").prop("lang")},msg:Q,Notification:ee,PasswordConfirmation:te.a,Plugins:{_plugins:{},register:function(e,t){var n=this._plugins[e];n||(n=this._plugins[e]=[]),n.push(t)},getPlugins:function(e){return this._plugins[e]||[]},attach:function(e,t,n){for(var a=this.getPlugins(e),r=0;r<a.length;r++)a[r].attach&&a[r].attach(t,n)},detach:function(e,t,n){for(var a=this.getPlugins(e),r=0;r<a.length;r++)a[r].detach&&a[r].detach(t,n)}},search:ae,Util:oe,debug:de,filePath:Z.a,generateUrl:Z.b,get:(ce=window,function(e){for(var t=e.split("."),n=t.pop(),a=0;a<t.length;a++)if(!(ce=ce[t[a]]))return!1;return ce[n]}),set:function(e){return function(t,n){for(var a=t.split("."),r=a.pop(),i=0;i<a.length;i++)e[a[i]]||(e[a[i]]={}),e=e[a[i]];e[r]=n}}(window),getRootPath:Z.c,imagePath:Z.d,redirect:function(e){return window.location=e},reload:function(){return window.location.reload()},requestToken:Object(N.a)(),linkTo:Z.e,linkToOCS:Z.f,linkToRemote:Z.g,linkToRemoteBase:Z.h,webroot:_e};
*/if(void 0===ue){var le=(ue=location.pathname).indexOf("/index.php/");ue=-1!==le?ue.substr(0,le):ue.substr(0,ue.lastIndexOf("/"))}var ce,_e=ue,me=a.a={coreApps:j.i,menuSpeed:j.j,PERMISSION_ALL:j.a,PERMISSION_CREATE:j.b,PERMISSION_DELETE:j.c,PERMISSION_NONE:j.d,PERMISSION_READ:j.e,PERMISSION_SHARE:j.f,PERMISSION_UPDATE:j.g,TAG_FAVORITE:j.h,addScript:function(e,t,n){var a;console.warn("OC.addScript is deprecated, use OCP.Loader.loadScript instead");var r=OC.filePath(e,"js",t+".js");return o[r]?n&&n():(a=s.a.Deferred(),s.a.getScript(r,function(){return a.resolve()}),o[r]=a),o[r]},addStyle:function(e,t){console.warn("OC.addStyle is deprecated, use OCP.Loader.loadStylesheet instead");var n=OC.filePath(e,"css",t+".css");-1===d.indexOf(n)&&(d.push(n),document.createStyleSheet?document.createStyleSheet(n):(t=s()('<link rel="stylesheet" type="text/css" href="'+n+'"/>'),s()("head").append(t)))},Apps:u.a,AppConfig:_,appConfig:c,appswebroots:m,Backbone:b,ContactsMenu:P.a,config:H,currentUser:E,dialogs:W,EventSource:I,getCurrentUser:function(){return{uid:E,displayName:O}},isUserAdmin:function(){return q},L10N:K,_capabilities:$(),getCapabilities:$,hideMenus:U,registerMenu:function(e,t,n,a){t.addClass("menu"),e.on("A"===e.prop("tagName")?"click.menu":"click.menu keyup.menu",function(r){r.preventDefault(),r.key&&"Enter"!==r.key||(t.is(J)?U():(J&&U(),!0===a&&t.parent().addClass("openedMenu"),e.attr("aria-expanded",!0),t.slideToggle(j.j,n),J=t,e))})},showMenu:function(e,t,n){t.is(J)||(U(),J=t,e,t.trigger(new s.a.Event("beforeShow")),t.show(),t.trigger(new s.a.Event("afterShow")),y.a.isFunction(n)&&n())},unregisterMenu:function(e,t){t.is(J)&&U(),e.off("click.menu").removeClass("menutoggle"),t.removeClass("menu")},basename:function(e){return e.replace(/\\/g,"/").replace(/.*\//,"")},encodePath:function(e){if(!e)return e;for(var t=e.split("/"),n=[],a=0;a<t.length;a++)n.push(encodeURIComponent(t[a]));return n.join("/")},dirname:function(e){return e.replace(/\\/g,"/").replace(/\/[^\/]*$/,"")},isSamePath:function(e,t){var n=(e||"").split("/").filter(function(e){return"."!==e}),a=(t||"").split("/").filter(function(e){return"."!==e});return(e=S.apply(void 0,n))===(t=S.apply(void 0,a))},joinPaths:S,getHost:function(){return window.location.host},getHostName:function(){return window.location.hostname},getPort:function(){return window.location.port},getProtocol:function(){return window.location.protocol.split(":")[0]},getCanonicalLocale:function(){var e=X();return"string"==typeof e?e.replace(/_/g,"-"):e},getLocale:X,getLanguage:function(){return s()("html").prop("lang")},addTranslations:K.load,msg:Q,Notification:ee,PasswordConfirmation:te.a,Plugins:{_plugins:{},register:function(e,t){var n=this._plugins[e];n||(n=this._plugins[e]=[]),n.push(t)},getPlugins:function(e){return this._plugins[e]||[]},attach:function(e,t,n){for(var a=this.getPlugins(e),r=0;r<a.length;r++)a[r].attach&&a[r].attach(t,n)},detach:function(e,t,n){for(var a=this.getPlugins(e),r=0;r<a.length;r++)a[r].detach&&a[r].detach(t,n)}},search:ae,Util:oe,debug:de,filePath:Z.a,generateUrl:Z.b,get:(ce=window,function(e){for(var t=e.split("."),n=t.pop(),a=0;a<t.length;a++)if(!(ce=ce[t[a]]))return!1;return ce[n]}),set:function(e){return function(t,n){for(var a=t.split("."),r=a.pop(),i=0;i<a.length;i++)e[a[i]]||(e[a[i]]={}),e=e[a[i]];e[r]=n}}(window),getRootPath:Z.c,imagePath:Z.d,redirect:function(e){return window.location=e},reload:function(){return window.location.reload()},requestToken:Object(N.a)(),linkTo:Z.e,linkToOCS:Z.f,linkToRemote:Z.g,linkToRemoteBase:Z.h,webroot:_e};
/*
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*

File diff suppressed because one or more lines are too long

View File

@ -117,7 +117,7 @@ function oe(e){for(var t,n=[],i=0,r=-1,s=0;i<e.length;){t=e.charAt(i);var o=!s&&
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/if(void 0===ce){var ue=(ce=location.pathname).indexOf("/index.php/");ce=-1!==ue?ce.substr(0,ue):ce.substr(0,ce.lastIndexOf("/"))}var de,he=ce,pe=i.a={coreApps:C.i,menuSpeed:C.j,PERMISSION_ALL:C.a,PERMISSION_CREATE:C.b,PERMISSION_DELETE:C.c,PERMISSION_NONE:C.d,PERMISSION_READ:C.e,PERMISSION_SHARE:C.f,PERMISSION_UPDATE:C.g,TAG_FAVORITE:C.h,addScript:function(e,t,n){var i;console.warn("OC.addScript is deprecated, use OCP.Loader.loadScript instead");var r=OC.filePath(e,"js",t+".js");return a[r]?n&&n():(i=o.a.Deferred(),o.a.getScript(r,function(){return i.resolve()}),a[r]=i),a[r]},addStyle:function(e,t){console.warn("OC.addStyle is deprecated, use OCP.Loader.loadStylesheet instead");var n=OC.filePath(e,"css",t+".css");-1===l.indexOf(n)&&(l.push(n),document.createStyleSheet?document.createStyleSheet(n):(t=o()('<link rel="stylesheet" type="text/css" href="'+n+'"/>'),o()("head").append(t)))},Apps:c.a,AppConfig:h,appConfig:d,appswebroots:p,Backbone:D,ContactsMenu:E.a,config:S,currentUser:O,dialogs:z,EventSource:B,getCurrentUser:function(){return{uid:O,displayName:P}},isUserAdmin:function(){return q},L10N:K,_capabilities:R(),getCapabilities:R,hideMenus:Q,registerMenu:function(e,t,n,i){t.addClass("menu"),e.on("A"===e.prop("tagName")?"click.menu":"click.menu keyup.menu",function(r){r.preventDefault(),r.key&&"Enter"!==r.key||(t.is(U)?Q():(U&&Q(),!0===i&&t.parent().addClass("openedMenu"),e.attr("aria-expanded",!0),t.slideToggle(C.j,n),U=t,e))})},showMenu:function(e,t,n){t.is(U)||(Q(),U=t,e,t.trigger(new o.a.Event("beforeShow")),t.show(),t.trigger(new o.a.Event("afterShow")),_.a.isFunction(n)&&n())},unregisterMenu:function(e,t){t.is(U)&&Q(),e.off("click.menu").removeClass("menutoggle"),t.removeClass("menu")},basename:function(e){return e.replace(/\\/g,"/").replace(/.*\//,"")},encodePath:function(e){if(!e)return e;for(var t=e.split("/"),n=[],i=0;i<t.length;i++)n.push(encodeURIComponent(t[i]));return n.join("/")},dirname:function(e){return e.replace(/\\/g,"/").replace(/\/[^\/]*$/,"")},isSamePath:function(e,t){var n=(e||"").split("/").filter(function(e){return"."!==e}),i=(t||"").split("/").filter(function(e){return"."!==e});return(e=Y.apply(void 0,n))===(t=Y.apply(void 0,i))},joinPaths:Y,getHost:function(){return window.location.host},getHostName:function(){return window.location.hostname},getPort:function(){return window.location.port},getProtocol:function(){return window.location.protocol.split(":")[0]},getCanonicalLocale:function(){var e=X();return"string"==typeof e?e.replace(/_/g,"-"):e},getLocale:X,getLanguage:function(){return o()("html").prop("lang")},msg:$,Notification:ee,PasswordConfirmation:te.a,Plugins:{_plugins:{},register:function(e,t){var n=this._plugins[e];n||(n=this._plugins[e]=[]),n.push(t)},getPlugins:function(e){return this._plugins[e]||[]},attach:function(e,t,n){for(var i=this.getPlugins(e),r=0;r<i.length;r++)i[r].attach&&i[r].attach(t,n)},detach:function(e,t,n){for(var i=this.getPlugins(e),r=0;r<i.length;r++)i[r].detach&&i[r].detach(t,n)}},search:ie,Util:ae,debug:le,filePath:Z.a,generateUrl:Z.b,get:(de=window,function(e){for(var t=e.split("."),n=t.pop(),i=0;i<t.length;i++)if(!(de=de[t[i]]))return!1;return de[n]}),set:function(e){return function(t,n){for(var i=t.split("."),r=i.pop(),s=0;s<i.length;s++)e[i[s]]||(e[i[s]]={}),e=e[i[s]];e[r]=n}}(window),getRootPath:Z.c,imagePath:Z.d,redirect:function(e){return window.location=e},reload:function(){return window.location.reload()},requestToken:Object(F.a)(),linkTo:Z.e,linkToOCS:Z.f,linkToRemote:Z.g,linkToRemoteBase:Z.h,webroot:he};
*/if(void 0===ce){var ue=(ce=location.pathname).indexOf("/index.php/");ce=-1!==ue?ce.substr(0,ue):ce.substr(0,ce.lastIndexOf("/"))}var de,he=ce,pe=i.a={coreApps:C.i,menuSpeed:C.j,PERMISSION_ALL:C.a,PERMISSION_CREATE:C.b,PERMISSION_DELETE:C.c,PERMISSION_NONE:C.d,PERMISSION_READ:C.e,PERMISSION_SHARE:C.f,PERMISSION_UPDATE:C.g,TAG_FAVORITE:C.h,addScript:function(e,t,n){var i;console.warn("OC.addScript is deprecated, use OCP.Loader.loadScript instead");var r=OC.filePath(e,"js",t+".js");return a[r]?n&&n():(i=o.a.Deferred(),o.a.getScript(r,function(){return i.resolve()}),a[r]=i),a[r]},addStyle:function(e,t){console.warn("OC.addStyle is deprecated, use OCP.Loader.loadStylesheet instead");var n=OC.filePath(e,"css",t+".css");-1===l.indexOf(n)&&(l.push(n),document.createStyleSheet?document.createStyleSheet(n):(t=o()('<link rel="stylesheet" type="text/css" href="'+n+'"/>'),o()("head").append(t)))},Apps:c.a,AppConfig:h,appConfig:d,appswebroots:p,Backbone:D,ContactsMenu:E.a,config:S,currentUser:O,dialogs:z,EventSource:B,getCurrentUser:function(){return{uid:O,displayName:P}},isUserAdmin:function(){return q},L10N:K,_capabilities:R(),getCapabilities:R,hideMenus:Q,registerMenu:function(e,t,n,i){t.addClass("menu"),e.on("A"===e.prop("tagName")?"click.menu":"click.menu keyup.menu",function(r){r.preventDefault(),r.key&&"Enter"!==r.key||(t.is(U)?Q():(U&&Q(),!0===i&&t.parent().addClass("openedMenu"),e.attr("aria-expanded",!0),t.slideToggle(C.j,n),U=t,e))})},showMenu:function(e,t,n){t.is(U)||(Q(),U=t,e,t.trigger(new o.a.Event("beforeShow")),t.show(),t.trigger(new o.a.Event("afterShow")),_.a.isFunction(n)&&n())},unregisterMenu:function(e,t){t.is(U)&&Q(),e.off("click.menu").removeClass("menutoggle"),t.removeClass("menu")},basename:function(e){return e.replace(/\\/g,"/").replace(/.*\//,"")},encodePath:function(e){if(!e)return e;for(var t=e.split("/"),n=[],i=0;i<t.length;i++)n.push(encodeURIComponent(t[i]));return n.join("/")},dirname:function(e){return e.replace(/\\/g,"/").replace(/\/[^\/]*$/,"")},isSamePath:function(e,t){var n=(e||"").split("/").filter(function(e){return"."!==e}),i=(t||"").split("/").filter(function(e){return"."!==e});return(e=Y.apply(void 0,n))===(t=Y.apply(void 0,i))},joinPaths:Y,getHost:function(){return window.location.host},getHostName:function(){return window.location.hostname},getPort:function(){return window.location.port},getProtocol:function(){return window.location.protocol.split(":")[0]},getCanonicalLocale:function(){var e=X();return"string"==typeof e?e.replace(/_/g,"-"):e},getLocale:X,getLanguage:function(){return o()("html").prop("lang")},addTranslations:K.load,msg:$,Notification:ee,PasswordConfirmation:te.a,Plugins:{_plugins:{},register:function(e,t){var n=this._plugins[e];n||(n=this._plugins[e]=[]),n.push(t)},getPlugins:function(e){return this._plugins[e]||[]},attach:function(e,t,n){for(var i=this.getPlugins(e),r=0;r<i.length;r++)i[r].attach&&i[r].attach(t,n)},detach:function(e,t,n){for(var i=this.getPlugins(e),r=0;r<i.length;r++)i[r].detach&&i[r].detach(t,n)}},search:ie,Util:ae,debug:le,filePath:Z.a,generateUrl:Z.b,get:(de=window,function(e){for(var t=e.split("."),n=t.pop(),i=0;i<t.length;i++)if(!(de=de[t[i]]))return!1;return de[n]}),set:function(e){return function(t,n){for(var i=t.split("."),r=i.pop(),s=0;s<i.length;s++)e[i[s]]||(e[i[s]]={}),e=e[i[s]];e[r]=n}}(window),getRootPath:Z.c,imagePath:Z.d,redirect:function(e){return window.location=e},reload:function(){return window.location.reload()},requestToken:Object(F.a)(),linkTo:Z.e,linkToOCS:Z.f,linkToRemote:Z.g,linkToRemoteBase:Z.h,webroot:he};
/*
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*

File diff suppressed because one or more lines are too long

View File

@ -17,20 +17,6 @@ Object.assign(window.OC, {
return !!(file.match(OC.config.blacklist_files_regex));
},
/**
},
/**
* Loads translations for the given app asynchronously.
*
* @param {String} app app name
* @param {Function} callback callback to call after loading
* @return {Promise}
*/
addTranslations: function(app, callback) {
return OC.L10N.load(app, callback);
},
/**
* Parses a URL query string into a JS map
* @param {string} queryString query string in the format param1=1234&param2=abcde&param3=xyz

View File

@ -177,6 +177,15 @@ export default {
getCanonicalLocale,
getLocale,
getLanguage,
/**
* Loads translations for the given app asynchronously.
*
* @param {String} app app name
* @param {Function} callback callback to call after loading
* @return {Promise}
* @deprecated 17.0.0 use OC.L10N.load instead
*/
addTranslations: L10N.load,
msg,
Notification,