Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
angular-translate-loader-static-files
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Custom Issue Tracker
Custom Issue Tracker
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
angularjs
angular-translate-loader-static-files
Commits
e740ff25
Commit
e740ff25
authored
Jan 23, 2019
by
bingchuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev] version 2.13.1
parent
4d391e92
Pipeline
#81
canceled with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
1 deletion
+113
-1
bower.json
bower.json
+1
-1
translate-loader-static-files.js
translate-loader-static-files.js
+112
-0
No files found.
bower.json
View file @
e740ff25
...
...
@@ -2,7 +2,7 @@
"name"
:
"angular-translate-loader-static-files"
,
"description"
:
"A plugin for Angular Translate"
,
"version"
:
"2.13.1"
,
"main"
:
"./
angular-
translate-loader-static-files.js"
,
"main"
:
"./translate-loader-static-files.js"
,
"ignore"
:
[],
"author"
:
"Pascal Precht"
,
"license"
:
"MIT"
,
...
...
translate-loader-static-files.js
0 → 100644
View file @
e740ff25
/*!
* angular-translate - v2.13.1 - 2016-12-06
*
* Copyright (c) 2016 The angular-translate team, Pascal Precht; Licensed MIT
*/
(
function
(
root
,
factory
)
{
if
(
typeof
define
===
'function'
&&
define
.
amd
)
{
// AMD. Register as an anonymous module unless amdModuleId is set
define
([],
function
()
{
return
(
factory
());
});
}
else
if
(
typeof
exports
===
'object'
)
{
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module
.
exports
=
factory
();
}
else
{
factory
();
}
}(
this
,
function
()
{
$translateStaticFilesLoader
.
$inject
=
[
'$q'
,
'$http'
];
angular
.
module
(
'pascalprecht.translate'
)
/**
* @ngdoc object
* @name pascalprecht.translate.$translateStaticFilesLoader
* @requires $q
* @requires $http
*
* @description
* Creates a loading function for a typical static file url pattern:
* "lang-en_US.json", "lang-de_DE.json", etc. Using this builder,
* the response of these urls must be an object of key-value pairs.
*
* @param {object} options Options object, which gets prefix, suffix, key, and fileMap
*/
.
factory
(
'$translateStaticFilesLoader'
,
$translateStaticFilesLoader
);
function
$translateStaticFilesLoader
(
$q
,
$http
)
{
'use strict'
;
return
function
(
options
)
{
if
(
!
options
||
(
!
angular
.
isArray
(
options
.
files
)
&&
(
!
angular
.
isString
(
options
.
prefix
)
||
!
angular
.
isString
(
options
.
suffix
))))
{
throw
new
Error
(
'Couldn
\'
t load static files, no files and prefix or suffix specified!'
);
}
if
(
!
options
.
files
)
{
options
.
files
=
[{
prefix
:
options
.
prefix
,
suffix
:
options
.
suffix
}];
}
var
load
=
function
(
file
)
{
if
(
!
file
||
(
!
angular
.
isString
(
file
.
prefix
)
||
!
angular
.
isString
(
file
.
suffix
)))
{
throw
new
Error
(
'Couldn
\'
t load static file, no prefix or suffix specified!'
);
}
var
fileUrl
=
[
file
.
prefix
,
options
.
key
,
file
.
suffix
].
join
(
''
);
if
(
angular
.
isObject
(
options
.
fileMap
)
&&
options
.
fileMap
[
fileUrl
])
{
fileUrl
=
options
.
fileMap
[
fileUrl
];
}
return
$http
(
angular
.
extend
({
url
:
fileUrl
,
method
:
'GET'
,
params
:
''
},
options
.
$http
))
.
then
(
function
(
result
)
{
return
result
.
data
;
},
function
()
{
return
$q
.
reject
(
options
.
key
);
});
};
var
promises
=
[],
length
=
options
.
files
.
length
;
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
promises
.
push
(
load
({
prefix
:
options
.
files
[
i
].
prefix
,
key
:
options
.
key
,
suffix
:
options
.
files
[
i
].
suffix
}));
}
return
$q
.
all
(
promises
)
.
then
(
function
(
data
)
{
var
length
=
data
.
length
,
mergedData
=
{};
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
for
(
var
key
in
data
[
i
])
{
mergedData
[
key
]
=
data
[
i
][
key
];
}
}
return
mergedData
;
});
};
}
$translateStaticFilesLoader
.
displayName
=
'$translateStaticFilesLoader'
;
return
'pascalprecht.translate'
;
}));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment