Skip to content

Commit 6becff7

Browse files
committed
initial implementation
0 parents  commit 6becff7

19 files changed

Lines changed: 829 additions & 0 deletions

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea/
2+
/node_modules/
3+
/npm-debug.log

.jshintrc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"bitwise": true,
3+
"boss": true,
4+
"browser": true,
5+
"camelcase": false,
6+
"curly": true,
7+
"eqeqeq": true,
8+
"expr": true,
9+
"esnext": true,
10+
"forin": true,
11+
"globals": {
12+
"_": false,
13+
"after": false,
14+
"afterEach": false,
15+
"angular": false,
16+
"assert": false,
17+
"before": false,
18+
"beforeEach": false,
19+
"browserTrigger": false,
20+
"debugger": false,
21+
"describe": false,
22+
"expect": false,
23+
"it": false,
24+
"inject": false,
25+
"module": false,
26+
"Parse": false,
27+
"sinon": false
28+
},
29+
"immed": true,
30+
"indent": 2,
31+
"jquery": true,
32+
"latedef": true,
33+
"maxcomplexity": 10,
34+
"maxdepth": 2,
35+
"maxerr": 100,
36+
"maxlen": 120,
37+
"maxparams": 4,
38+
"maxstatements": 8,
39+
"newcap": true,
40+
"noarg": true,
41+
"node": true,
42+
"noempty": true,
43+
"nonew": true,
44+
"onevar": false,
45+
"phantom": true,
46+
"plusplus": true,
47+
"quotmark": "single",
48+
"strict": false,
49+
"trailing": false,
50+
"undef": true,
51+
"unused": true,
52+
"white": true
53+
}
54+

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.10.32

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2015 Steven Nance <steve@devtrw.com>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
19+
THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
angular-devtrw-translate
2+
===
3+
4+
Provides a `translate-base` and `translate-child` directive that wrap angular-translate
5+
functionality.
6+
7+
`translate-base` sets a base translation key that will be prepended to any `translate-child`
8+
directives.
9+
10+
See the `demo/index.html` file for example usage.
11+
12+
Installation
13+
===
14+
15+
1. Install the source files using bower: `bower install angular-devtrw-translate`
16+
2. Include either source file in `dist/`, they are both the same.
17+
18+
__Note:__ _Both files have the same content however one has a hash of the file appended to
19+
the filename and will change with each version. The revisioned filename is referenced in
20+
the `main` section of the contained `bower.json` for use with automated build tools._
21+
3. Include the `dtrw.translate` module in your Angular app
22+
23+
Usage
24+
===
25+
26+
See the demo/index.html for usage examples. If this gains any useage outside of our internal team I
27+
will add some more documentation here. Shoot me an email at <steven@devtrw.com> if you need any
28+
help.
29+
30+
License
31+
===
32+
See the included LICENSE file.

bower.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "angular-devtrw-translate",
3+
"main": [
4+
"dist/angular-devtrw-translate.js"
5+
],
6+
"version": "0.1.0",
7+
"description": "Provides translate-base and translate-child directives for angular-translate",
8+
"authors": [
9+
"Steven Nance <steven@devtrw.com>"
10+
],
11+
"keywords": [
12+
"angular",
13+
"angularjs",
14+
"javascript",
15+
"translate",
16+
"translations",
17+
"angular-translate"
18+
],
19+
"ignore": [
20+
"**/.*",
21+
"bower_components",
22+
"gulpfile.js",
23+
"node_modules",
24+
"package.json",
25+
"src"
26+
],
27+
"overrides": {
28+
"angular": {
29+
"ignore": true
30+
}
31+
},
32+
"dependencies": {
33+
"angular": "*",
34+
},
35+
"devDependencies": { }
36+
}

demo/index.html

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
<!DOCTYPE html>
2+
<html ng-app="dtrw.translate">
3+
<head lang="en">
4+
<meta charset="UTF-8">
5+
<title>Angular DevTRW Translations Demo</title>
6+
<style>
7+
.page {
8+
border: 1px solid #eee;
9+
width: 300px;
10+
padding: 15px;
11+
}
12+
13+
.label {
14+
display: block;
15+
}
16+
17+
input {
18+
width: 100%;
19+
}
20+
</style>
21+
</head>
22+
<body translate-base="dtrw.translate">
23+
<h1>Angular DevTRW Translations Demo</h1>
24+
25+
<h2>Example Usage</h2>
26+
27+
<h3>Template HTML</h3>
28+
<pre>
29+
&lt;body translate-base="dtrw.translate"&gt;
30+
&lt;div translate-base="states.login"
31+
class="page"
32+
ng-init="lastLoginUsername = 'someUserName'"&gt;
33+
&lt;div translate-base="LAST_LOGIN"&gt;
34+
&lt;p translate-child="DETAILS" translate-values="{username: lastLoginUsername}"&gt;&lt;/p&gt;
35+
&lt;/div&gt;
36+
&lt;div translate-base="USERNAME_FORM"&gt;
37+
&lt;h4 translate-child="TITLE"&gt;&lt;/h4&gt;
38+
39+
&lt;form&gt;
40+
&lt;div class="form-group" translate-base="USERNAME"&gt;
41+
&lt;label translate-child="LABEL" for="username-input"&gt;&lt;/label&gt;
42+
&lt;input type="text"
43+
id="username-input"
44+
translate-child="PLACEHOLDER"
45+
translate-values="{lastLoginUser: lastLoginUsername}"
46+
translate-child-into="placeholder"&gt;
47+
&lt;/div&gt;
48+
&lt;/form&gt;
49+
&lt;/div&gt;
50+
&lt;div translate-base="PASSWORD_FORM"&gt;
51+
&lt;h4 translate-child="TITLE"&gt;&lt;/h4&gt;
52+
53+
&lt;form&gt;
54+
&lt;div class="form-group" translate-base="PASSWORD"&gt;
55+
&lt;label translate-child="LABEL" for="password-input"&gt;&lt;/label&gt;
56+
&lt;input type="text" id="password-input"
57+
translate-child="PLACEHOLDER"
58+
translate-child-into="placeholder"&gt;
59+
&lt;/div&gt;
60+
&lt;/form&gt;
61+
&lt;/div&gt;
62+
&lt;/div&gt;
63+
&lt;/body&gt;
64+
</pre>
65+
<h3>Translations</h3>
66+
<pre ng-non-bindable>
67+
angular.module('dtrw.translate').config(function ($translateProvider) {
68+
$translateProvider.preferredLanguage('en');
69+
$translateProvider.translations('en', {
70+
dtrw: {
71+
translate: {
72+
states: {
73+
login: {
74+
LAST_LOGIN: {
75+
DETAILS: 'Last logging in as &lt;b&gt;{{ username }}&lt;/b&gt;'
76+
},
77+
USERNAME_FORM: {
78+
TITLE: 'Username Form',
79+
USERNAME: {
80+
LABEL: 'Username',
81+
PLACEHOLDER: '{{ lastLoginUser }}'
82+
}
83+
},
84+
PASSWORD_FORM: {
85+
TITLE: 'Password Form',
86+
PASSWORD: {
87+
LABEL: 'Password',
88+
PLACEHOLDER: 'Enter Your Password'
89+
}
90+
}
91+
}
92+
}
93+
}
94+
}
95+
});
96+
})
97+
</pre>
98+
99+
100+
<h3>Rendered</h3>
101+
102+
<div translate-base="states.login"
103+
class="page"
104+
ng-init="lastLoginUsername = 'someUserName'">
105+
<div translate-base="LAST_LOGIN">
106+
<p translate-child="DETAILS" translate-values="{username: lastLoginUsername}"></p>
107+
</div>
108+
<div translate-base="USERNAME_FORM">
109+
<h4 translate-child="TITLE"></h4>
110+
111+
<form>
112+
<div class="form-group" translate-base="USERNAME">
113+
<label translate-child="LABEL" for="username-input"></label>
114+
<input type="text"
115+
id="username-input"
116+
translate-child="PLACEHOLDER"
117+
translate-values="{lastLoginUser: lastLoginUsername}"
118+
translate-child-into="placeholder">
119+
</div>
120+
</form>
121+
</div>
122+
<div translate-base="PASSWORD_FORM">
123+
<h4 translate-child="TITLE"></h4>
124+
125+
<form>
126+
<div class="form-group" translate-base="PASSWORD">
127+
<label translate-child="LABEL" for="password-input"></label>
128+
<input type="text" id="password-input"
129+
translate-child="PLACEHOLDER"
130+
translate-child-into="placeholder">
131+
</div>
132+
</form>
133+
</div>
134+
</div>
135+
136+
<script src="../node_modules/angular/angular.js"></script>
137+
<script src="../node_modules/angular-translate/dist/angular-translate.js"></script>
138+
<script src="../dist/angular-devtrw-translate.js"></script>
139+
<script>
140+
angular.module('dtrw.translate').config(function ($translateProvider) {
141+
$translateProvider.preferredLanguage('en');
142+
$translateProvider.translations('en', {
143+
dtrw: {
144+
translate: {
145+
states: {
146+
login: {
147+
LAST_LOGIN: {
148+
DETAILS: 'Last logging in as <b>{{ username }}</b>'
149+
},
150+
USERNAME_FORM: {
151+
TITLE: 'Username Form',
152+
USERNAME: {
153+
LABEL: 'Username',
154+
PLACEHOLDER: '{{ lastLoginUser }}'
155+
}
156+
},
157+
PASSWORD_FORM: {
158+
TITLE: 'Password Form',
159+
PASSWORD: {
160+
LABEL: 'Password',
161+
PLACEHOLDER: 'Enter Your Password'
162+
}
163+
}
164+
}
165+
}
166+
}
167+
}
168+
});
169+
})
170+
</script>
171+
</body>
172+
</html>

dist/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)