Skip to content
This repository was archived by the owner on May 13, 2018. It is now read-only.

Commit cdf1513

Browse files
committed
ローカライズを安定化。
1 parent 989e53a commit cdf1513

12 files changed

Lines changed: 167 additions & 133 deletions

File tree

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
<Div ID = "Top-Introduce" Data-Locales = "top.introduce">
2727
Simple Threadへようこそ!
28-
当サービスでは "Be Simple, Be Free" をモットーに、他サービスと比べ自由に話せるスレ板を提供しますΣd(´・ω・`)
28+
当サービスでは 'Be Simple, Be Free' をモットーに、他サービスと比べ自由に話せるスレ板を提供しますΣd(´・ω・`)
2929
</Div>
3030
</Main>
3131
</Body>

info/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
<Main ID = "Info">
2222
<Img ID = "Info-Logo" Src = "/SimpleThread/images/Logo.png" />
2323

24-
<H2 Class = "mdc-typography--headline" Data-Locales = "common.serverInfo">Server Info</H2>
24+
<H2 Class = "mdc-typography--headline" Data-Locales = "common.info">Info</H2>
2525

26-
<Table Class = "mdc-elevation--z3">
26+
<Table Class = "mdc-elevation--z2">
2727
<THead>
2828
<Tr>
2929
<Th Data-Locales = "info.name">項目</Th>

libraries/DBLoader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ class DBLoader extends FirebasePlus {
3939
}
4040
}
4141

42+
terminal.postMessage({ code: "LoaderLoaded" });
4243
terminal.postMessage({ code: "ScriptLoaded" });

libraries/FileLoader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ class FileLoader {
2323
}
2424
}
2525

26+
terminal.postMessage({ code: "LoaderLoaded" });
2627
terminal.postMessage({ code: "ScriptLoaded" });

libraries/JSONLoader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ class JSONLoader extends FileLoader {
1313
}
1414
}
1515

16+
terminal.postMessage({ code: "LoaderLoaded" });
1617
terminal.postMessage({ code: "ScriptLoaded" });

libraries/LangLoader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class LangLoader extends JSONLoader {
1212
* @param {String} lang
1313
*/
1414
load (lang) {
15-
return super.load(`/SimpleThread/assets/locales/${lang}.json`);
15+
return super.load(`/SimpleThread/locales/${lang}.json`);
1616
}
1717

1818
/**
@@ -52,4 +52,5 @@ class LangLoader extends JSONLoader {
5252
}
5353
}
5454

55+
terminal.postMessage({ code: "LoaderLoaded" });
5556
terminal.postMessage({ code: "ScriptLoaded" });

libraries/common/common.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
--mdc-theme-text-secondary-on-secondary: #b2ebf2;
1919
--mdc-theme-text-secondary-on-secondary-light: #b2ebf2;
2020
--mdc-theme-text-secondary-on-secondary-dark: #18ffff;
21+
22+
Line-Height: 1.75;
2123
}
2224

2325
HTML, Body {

libraries/common/common.js

Lines changed: 114 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
let base;
21
let terminal = new Worker("/SimpleThread/terminal.js");
2+
let base;
3+
let locales = null;
4+
5+
36

47
window.addEventListener("DOMContentLoaded", () => {
58
let menuContainer = new DOM.ComponentLoader("/SimpleThread/libraries/common/").doc.querySelector("Body");
@@ -43,115 +46,131 @@ window.addEventListener("DOMContentLoaded", () => {
4346

4447

4548
new DOM("@Main").forEach(elem => {
46-
["mdc-typography", "mdc-typography--body2", "mdc-elevation--z5", "mdc-toolbar-fixed-adjust"].forEach(className => elem.classList.add(className));
49+
["mdc-typography", "mdc-typography--body1", "mdc-elevation--z5", "mdc-toolbar-fixed-adjust"].forEach(className => elem.classList.add(className));
4750
});
4851

4952

5053

5154
terminal.addEventListener("message", event => {
52-
if (event.data.code == "Initialized") {
53-
base = new DBLoader("/SimpleThread/firebase.json", (user) => {
54-
/*window.gapi.load("picker", () => {
55-
window.Picker = class Picker extends google.picker.PickerBuilder {
56-
static get PhotoPicker () {
57-
return class PhotoPicker extends window.Picker {
58-
constructor (onSelect = (data) => {}) {
59-
super(onSelect);
60-
super.addView(google.picker.ViewId.PHOTOS);
55+
switch (event.data.code) {
56+
case "LocalizeInitialized":
57+
locales = new LangLoader();
58+
locales.load(localStorage.getItem("com.GenbuProject.SimpleThread.currentLang"));
59+
locales.apply(this);
60+
61+
break;
62+
63+
case "Initialized":
64+
base = new DBLoader("/SimpleThread/firebase.json", (user) => {
65+
/*window.gapi.load("picker", () => {
66+
window.Picker = class Picker extends google.picker.PickerBuilder {
67+
static get PhotoPicker () {
68+
return class PhotoPicker extends window.Picker {
69+
constructor (onSelect = (data) => {}) {
70+
super(onSelect);
71+
super.addView(google.picker.ViewId.PHOTOS);
72+
}
6173
}
6274
}
63-
}
64-
65-
static get FilePicker () {
66-
return class FilePicker extends window.Picker {
67-
constructor (onSelect = (data) => {}) {
68-
super(onSelect);
69-
super.addView(google.picker.ViewId.DOCS);
75+
76+
static get FilePicker () {
77+
return class FilePicker extends window.Picker {
78+
constructor (onSelect = (data) => {}) {
79+
super(onSelect);
80+
super.addView(google.picker.ViewId.DOCS);
81+
}
7082
}
7183
}
84+
85+
86+
87+
constructor (onSelect = (data) => {}) {
88+
super();
89+
90+
super.setOAuthToken(base.accessToken),
91+
super.setDeveloperKey(base.option.apiKey),
92+
super.setCallback(onSelect);
93+
}
94+
95+
show () {
96+
let picker = this.picker = this.build();
97+
picker.setVisible(true);
98+
}
99+
100+
dismiss () {
101+
this.picker.setVisible(false);
102+
}
72103
}
73-
74-
75-
76-
constructor (onSelect = (data) => {}) {
77-
super();
78-
79-
super.setOAuthToken(base.accessToken),
80-
super.setDeveloperKey(base.option.apiKey),
81-
super.setCallback(onSelect);
82-
}
83-
84-
show () {
85-
let picker = this.picker = this.build();
86-
picker.setVisible(true);
87-
}
88-
89-
dismiss () {
90-
this.picker.setVisible(false);
91-
}
92-
}
93-
});
94-
95-
96-
97-
if (user) {
98-
new DOM("#Header_SignInOut").dataset.locales = "main.signOut";
99-
100-
base.Database.getInfo(base.Database.ONCE, `users/${user.uid}`, (res) => {
101-
new DOM('@A[UUID="ProfilePhoto-Btn"]').forEach((btn) => {
102-
btn.dataset.uid = user.uid;
103-
});
104-
105-
if (!res.exists()) {
106-
base.Database.set(`users/${user.uid}`, {
107-
gplusName: user.providerData[0].displayName,
108-
gplusPhoto: user.photoURL,
109-
userName: user.providerData[0].displayName,
110-
detail: "",
111-
links: []
104+
});
105+
106+
107+
108+
if (user) {
109+
new DOM("#Header_SignInOut").dataset.locales = "main.signOut";
110+
111+
base.Database.getInfo(base.Database.ONCE, `users/${user.uid}`, (res) => {
112+
new DOM('@A[UUID="ProfilePhoto-Btn"]').forEach((btn) => {
113+
btn.dataset.uid = user.uid;
112114
});
113-
114-
new DOM("#Dialogs_Account_CreateNotify").showModal();
115-
} else {
116-
base.Database.update(`users/${user.uid}`, {
117-
gplusName: user.providerData[0].displayName,
118-
gplusPhoto: user.photoURL
115+
116+
if (!res.exists()) {
117+
base.Database.set(`users/${user.uid}`, {
118+
gplusName: user.providerData[0].displayName,
119+
gplusPhoto: user.photoURL,
120+
userName: user.providerData[0].displayName,
121+
detail: "",
122+
links: []
123+
});
124+
125+
new DOM("#Dialogs_Account_CreateNotify").showModal();
126+
} else {
127+
base.Database.update(`users/${user.uid}`, {
128+
gplusName: user.providerData[0].displayName,
129+
gplusPhoto: user.photoURL
130+
});
131+
}
132+
});
133+
134+
base.Database.get(base.Database.ONCE, `users/${base.user.uid}`, (res) => {
135+
new DOM("#Dialogs_Thread_Poster_Header_ActorPhoto").dataset.uid = base.user.uid;
136+
new DOM("#Dialogs_Thread_Poster_Header_Actor").textContent = res.userName;
137+
});
138+
} else {
139+
window.addEventListener("DOMContentLoaded", () => {
140+
new DOM('@*[UUID="ProfilePhoto-Btn"]').forEach((btn) => {
141+
btn.setAttribute("Disabled", "");
119142
});
120-
}
121-
});
122-
123-
base.Database.get(base.Database.ONCE, `users/${base.user.uid}`, (res) => {
124-
new DOM("#Dialogs_Thread_Poster_Header_ActorPhoto").dataset.uid = base.user.uid;
125-
new DOM("#Dialogs_Thread_Poster_Header_Actor").textContent = res.userName;
126-
});
127-
} else {
128-
window.addEventListener("DOMContentLoaded", () => {
129-
new DOM('@*[UUID="ProfilePhoto-Btn"]').forEach((btn) => {
130-
btn.setAttribute("Disabled", "");
131143
});
132-
});
133-
}
134-
135-
locales.applyToElement(new DOM("#Header_SignInOut"));
136-
137-
base.Database.get(base.Database.ONCE, "users", (res) => {
138-
for (let uid in res) {
139-
let photoStyle = new Component.Styles.ProfilePhotoManager(uid, res[uid].gplusPhoto);
140-
141-
document.head.appendChild(photoStyle);
142144
}
145+
146+
locales.applyToElement(new DOM("#Header_SignInOut"));
147+
148+
base.Database.get(base.Database.ONCE, "users", (res) => {
149+
for (let uid in res) {
150+
let photoStyle = new Component.Styles.ProfilePhotoManager(uid, res[uid].gplusPhoto);
151+
152+
document.head.appendChild(photoStyle);
153+
}
154+
});
155+
156+
157+
158+
let querys = location.querySort();
159+
160+
if (querys.TID) {
161+
new DOM("$IFrame.mdl-layout__content").src = `Thread/Viewer/?tid=${querys.TID}`;
162+
}*/
163+
164+
terminal.postMessage({ code: "DBConnected" });
143165
});
144-
145-
146-
147-
let querys = location.querySort();
148-
149-
if (querys.TID) {
150-
new DOM("$IFrame.mdl-layout__content").src = `Thread/Viewer/?tid=${querys.TID}`;
151-
}*/
152-
153-
terminal.postMessage({ code: "DBConnected" });
154-
});
166+
167+
break;
155168
}
156169
});
170+
});
171+
172+
window.addEventListener("DOMNodeInserted", (event) => {
173+
if (event.target.nodeName != "#text" && event.relatedNode.dataset && event.relatedNode.dataset.locales) {
174+
locales.applyToElement(event.relatedNode);
175+
}
157176
});

libraries/common/index.html

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
<Nav Class = "mdc-temporary-drawer__content mdc-list">
66
<A Class = "mdc-list-item" Href = "/SimpleThread/">
77
<I Class = "material-icons mdc-list-item__start-detail" Aria-Hidden = "true">home</I>
8-
Top
8+
<Span Data-Locales = "common.top">Top</Span>
99
</A>
1010

11-
<A Class = "mdc-list-item" Href = "/SimpleThread/">
11+
<A Class = "mdc-list-item" Href = "/SimpleThread/thread/">
1212
<I Class = "material-icons mdc-list-item__start-detail" Aria-Hidden = "true">subject</I>
13-
Thread
13+
<Span Data-Locales = "common.thread">Thread</Span>
1414
</A>
1515

1616
<A Class = "mdc-list-item" Href = "/SimpleThread/info/">
1717
<I Class = "material-icons mdc-list-item__start-detail" Aria-Hidden = "true">info</I>
18-
Server Info
18+
<Span Data-Locales = "common.info">Info</Span>
1919
</A>
2020
</Nav>
2121
</Nav>
@@ -25,16 +25,20 @@
2525
<Link Rel = "StyleSheet" Href = "/SimpleThread/libraries/Material Icons/material-icons.css" />
2626
<Link Rel = "StyleSheet" Href = "/SimpleThread/libraries/Material Icons Extended/material-icons-extended.css" />
2727

28-
<!-- Global site tag (gtag.js) - Google Analytics -->
29-
<Script Src = "https://www.googletagmanager.com/gtag/js?id=UA-111257667-2" Async = "Async"></Script>
30-
3128

3229

3330
<Header Data-Component = "Frame-Content_Toolbar" Class = "mdc-toolbar mdc-toolbar--fixed mdc-toolbar--waterfall mdc-elevation--z4">
3431
<Div Class = "mdc-toolbar__row">
3532
<Section Class = "mdc-toolbar__section mdc-toolbar__section--align-start">
3633
<A Data-Component = "Frame-Content_Toolbar_DrawerBtn" Class = "mdc-toolbar__menu-icon material-icons" Href = "javascript:void(0)">menu</A>
37-
<Span Data-Component = "Frame-Content_Toolbar_Title" Class = "mdc-toolbar__title">どっかのプログラなーいのサイト。</Span>
34+
<Span Data-Component = "Frame-Content_Toolbar_Title" Class = "mdc-toolbar__title"></Span>
35+
</Section>
36+
37+
<Section Class = "mdc-toolbar__section mdc-toolbar__section--align-end mdc-toolbar__section--shrink-to-fit">
38+
<Nav Class = "mdc-tab-bar">
39+
<A Class = "mdc-tab" Href = "/SimpleThread/" Data-Locales = "common.top">Top</A>
40+
<A Class = "mdc-tab" Href = "#" Data-Locales = "common.signIn">Sign In</A>
41+
</Nav>
3842
</Section>
3943
</Div>
4044
</Header>

locales/en_US.json

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
22
"common.title": "Simple Thread",
3+
"common.top": "Top",
4+
"common.thread": "Thread",
5+
"common.info": "Info",
6+
"common.signIn": "Sign In",
7+
"common.signOut": "Sign Out",
8+
"common.profileBtn-hint": "See your profile",
39
"common.dialog_yes": "Yes",
410
"common.dialog_no": "No",
511
"common.dialog_close": "Accept",
@@ -36,13 +42,6 @@
3642
"dialog.thread.poster.linkEmbedder-error": "Invalid URL",
3743
"dialog.thread.poster.linkEmbedder.add": "Add",
3844

39-
"main.top": "Top",
40-
"main.thread": "Thread",
41-
"main.serverInfo": "Server Info",
42-
"main.signIn": "Sign In",
43-
"main.signOut": "Sign Out",
44-
"main.profileBtn-hint": "See your profile",
45-
4645
"top.introduce": ["Welcome to Simple Thread!", "Our goal is 'Be Simple, Be Free', and we supply thread-service you could talk freely :D"],
4746

4847
"thread.searchPanel": "Searching threads",
@@ -53,12 +52,12 @@
5352

5453
"post.delete": "Delete",
5554

56-
"serverInfo.name": "Name",
57-
"serverInfo.value": "Value",
58-
"serverInfo.name.serviceName": "Service Name",
59-
"serverInfo.name.users": "Users",
60-
"serverInfo.name.threads": "Threads",
61-
"serverInfo.name.lastUpdated": "Last Updated",
55+
"info.name": "Name",
56+
"info.value": "Value",
57+
"info.name.serviceName": "Service Name",
58+
"info.name.users": "Users",
59+
"info.name.threads": "Threads",
60+
"info.name.lastUpdated": "Last Updated",
6261

6362
"profile.name": "Name...",
6463
"profile.detail": "Detail...",

0 commit comments

Comments
 (0)