Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
angular-translate-storage-local
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-storage-local
Commits
266ce040
Commit
266ce040
authored
Mar 21, 2021
by
bingchuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev] version 2.18.4
parent
db54ffc9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
91 deletions
+91
-91
angular-translate-storage-local.js
angular-translate-storage-local.js
+91
-91
No files found.
angular-translate-storage-local.js
View file @
266ce040
/*!
* angular-translate - v2.1
3.1 - 2016-12-06
*
* Copyright (c) 20
16
The angular-translate team, Pascal Precht; Licensed MIT
* angular-translate - v2.1
8.4 - 2021-01-14
*
* Copyright (c) 20
21
The angular-translate team, Pascal Precht; Licensed MIT
*/
(
function
(
root
,
factory
)
{
if
(
typeof
define
===
'function'
&&
define
.
amd
)
{
...
...
@@ -9,7 +9,7 @@
define
([],
function
()
{
return
(
factory
());
});
}
else
if
(
typeof
exports
===
'object'
)
{
}
else
if
(
typeof
module
===
'object'
&&
module
.
exports
)
{
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
...
...
@@ -19,105 +19,105 @@
}
}(
this
,
function
()
{
$translateLocalStorageFactory
.
$inject
=
[
'$window'
,
'$translateCookieStorage'
];
angular
.
module
(
'pascalprecht.translate'
)
/**
* @ngdoc object
* @name pascalprecht.translate.$translateLocalStorage
* @requires $window
* @requires $translateCookieStorage
*
* @description
* Abstraction layer for localStorage. This service is used when telling angular-translate
* to use localStorage as storage.
*
*/
.
factory
(
'$translateLocalStorage'
,
$translateLocalStorageFactory
);
function
$translateLocalStorageFactory
(
$window
,
$translateCookieStorage
)
{
'use strict'
;
$translateLocalStorageFactory
.
$inject
=
[
'$window'
,
'$translateCookieStorage'
];
angular
.
module
(
'pascalprecht.translate'
)
// Setup adapter
var
localStorageAdapter
=
(
function
(){
var
langKey
;
return
{
/**
* @ngdoc function
* @name pascalprecht.translate.$translateLocalStorage#get
* @methodOf pascalprecht.translate.$translateLocalStorage
* @ngdoc object
* @name pascalprecht.translate.$translateLocalStorage
* @requires $window
* @requires $translateCookieStorage
*
* @description
* Returns an item from localStorage by given name.
* Abstraction layer for localStorage. This service is used when telling angular-translate
* to use localStorage as storage.
*
* @param {string} name Item name
* @return {string} Value of item name
*/
get
:
function
(
name
)
{
if
(
!
langKey
)
{
langKey
=
$window
.
localStorage
.
getItem
(
name
);
}
.
factory
(
'$translateLocalStorage'
,
$translateLocalStorageFactory
);
return
langKey
;
},
/**
* @ngdoc function
* @name pascalprecht.translate.$translateLocalStorage#set
* @methodOf pascalprecht.translate.$translateLocalStorage
*
* @description
* Sets an item in localStorage by given name.
*
* @deprecated use #put
*
* @param {string} name Item name
* @param {string} value Item value
*/
set
:
function
(
name
,
value
)
{
langKey
=
value
;
$window
.
localStorage
.
setItem
(
name
,
value
);
},
/**
* @ngdoc function
* @name pascalprecht.translate.$translateLocalStorage#put
* @methodOf pascalprecht.translate.$translateLocalStorage
*
* @description
* Sets an item in localStorage by given name.
*
* @param {string} name Item name
* @param {string} value Item value
*/
put
:
function
(
name
,
value
)
{
langKey
=
value
;
$window
.
localStorage
.
setItem
(
name
,
value
);
}
};
}());
function
$translateLocalStorageFactory
(
$window
,
$translateCookieStorage
)
{
'use strict'
;
// Setup adapter
var
localStorageAdapter
=
(
function
(){
var
langKey
;
return
{
/**
* @ngdoc function
* @name pascalprecht.translate.$translateLocalStorage#get
* @methodOf pascalprecht.translate.$translateLocalStorage
*
* @description
* Returns an item from localStorage by given name.
*
* @param {string} name Item name
* @return {string} Value of item name
*/
get
:
function
(
name
)
{
if
(
!
langKey
)
{
langKey
=
$window
.
localStorage
.
getItem
(
name
);
}
var
hasLocalStorageSupport
=
'localStorage'
in
$window
;
if
(
hasLocalStorageSupport
)
{
var
testKey
=
'pascalprecht.translate.storageTest'
;
try
{
// this check have to be wrapped within a try/catch because on
// a SecurityError: Dom Exception 18 on iOS
if
(
$window
.
localStorage
!==
null
)
{
$window
.
localStorage
.
setItem
(
testKey
,
'foo'
);
$window
.
localStorage
.
removeItem
(
testKey
);
hasLocalStorageSupport
=
true
;
}
else
{
return
langKey
;
},
/**
* @ngdoc function
* @name pascalprecht.translate.$translateLocalStorage#set
* @methodOf pascalprecht.translate.$translateLocalStorage
*
* @description
* Sets an item in localStorage by given name.
*
* @deprecated use #put
*
* @param {string} name Item name
* @param {string} value Item value
*/
set
:
function
(
name
,
value
)
{
langKey
=
value
;
$window
.
localStorage
.
setItem
(
name
,
value
);
},
/**
* @ngdoc function
* @name pascalprecht.translate.$translateLocalStorage#put
* @methodOf pascalprecht.translate.$translateLocalStorage
*
* @description
* Sets an item in localStorage by given name.
*
* @param {string} name Item name
* @param {string} value Item value
*/
put
:
function
(
name
,
value
)
{
langKey
=
value
;
$window
.
localStorage
.
setItem
(
name
,
value
);
}
};
}());
var
hasLocalStorageSupport
=
'localStorage'
in
$window
;
if
(
hasLocalStorageSupport
)
{
var
testKey
=
'pascalprecht.translate.storageTest'
;
try
{
// this check have to be wrapped within a try/catch because on
// a SecurityError: Dom Exception 18 on iOS
if
(
$window
.
localStorage
!==
null
)
{
$window
.
localStorage
.
setItem
(
testKey
,
'foo'
);
$window
.
localStorage
.
removeItem
(
testKey
);
hasLocalStorageSupport
=
true
;
}
else
{
hasLocalStorageSupport
=
false
;
}
}
catch
(
e
){
hasLocalStorageSupport
=
false
;
}
}
catch
(
e
){
hasLocalStorageSupport
=
false
;
}
var
$translateLocalStorage
=
hasLocalStorageSupport
?
localStorageAdapter
:
$translateCookieStorage
;
return
$translateLocalStorage
;
}
var
$translateLocalStorage
=
hasLocalStorageSupport
?
localStorageAdapter
:
$translateCookieStorage
;
return
$translateLocalStorage
;
}
$translateLocalStorageFactory
.
displayName
=
'$translateLocalStorageFactory'
;
return
'pascalprecht.translate'
;
$translateLocalStorageFactory
.
displayName
=
'$translateLocalStorageFactory'
;
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