Skip to content

Commit

Permalink
internationalisation eeeeee
Browse files Browse the repository at this point in the history
  • Loading branch information
Electogenius committed Nov 28, 2021
1 parent 02c7af3 commit 989f28a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 50 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<script type="text/javascript" src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>-->
<script src="main.js" charset="utf-8"></script>
<script src="cmd.js" type="text/javascript" charset="utf-8"></script>
<script src="langs.js"></script>
</body>

</html>
31 changes: 31 additions & 0 deletions langs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
hmm.storage.i18n = {}
hmm.storage.i18n.en = {
"welcome": "Welcome to HmmOS!",
"menu": {
"apps-label": "Apps"
},
"apps": {
"settings": {
"lang": "System language",
"name": "Settings"
}
}
}
hmm.storage.i18n.cd = {
welcome: "HmmOSk wangõ!",
menu: {
"apps-label": "selīng"
},
apps: {
settings: {
lang: "kãiod moi",
name: "māthrdhng"
}
}
}
for (lang in hmm.storage.i18n) {
hmm.l[lang] = new Polyglot({
locale: lang,
phrases: hmm.storage.i18n[lang]
})
}
69 changes: 19 additions & 50 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,16 @@ window.hmm = {
(p.match(/\/[^/]+/g) || []).forEach((e) => cr = cr[e.slice(1)])
return cr
},
pathToDot(p){
return "hmm.storage[atob('"+p.replace(/^\//,"").split('/').map(btoa).join("')][atob('")+"')]"
pathToDot(p) {
return "hmm.storage[atob('" + p.replace(/^\//, "").split('/').map(btoa).join("')][atob('") + "')]"
}
}
hmm.l.en = new Polyglot({
locale: "en",
phrases: {
"welcome": "Welcome to HmmOS!",
"menu": {
"apps-label": "Apps"
},
"apps": {
"settings": {
"lang": "System language",
"name": "Settings",
_name: "Settings"
}
}
}
})
hmm.l.cd = new Polyglot({
locale: "cd",
phrases: {
welcome: "HmmOSk wangõ!",
menu: {
"apps-label": "selīng"
},
apps: {
settings: {
lang: "kãiod moi",
name: "māthrdhng",
_name: "māthrdhng"
}
}
}
})

hmm.storage = {
name:"HmmOS (tm)",
name: "HmmOS (tm)",
apps: {
"app.hmm": {
title: "testapp with a particularly long title",
title: { en: "Test app", cd: "edhō" },
type: "iframe",
code: `
<script>
Expand All @@ -76,18 +45,18 @@ hmm.storage = {
</script>
`
},
"cmd.hmm": {
title: "Terminal",
"terminal.hmm": {
title: { en: "Terminal" },
type: 0,
code: ``
},
"opts.hmm": {
title: "settings",
"settings.hmm": {
title: { en: "settings", cd:"māthrdhng" },
type: "iframe",
code: "<script>location='./settings.html'</script>",
},
"fe.hmm": {
title: "Files",
title: { en: "Files", cd:"kōpnge" },
type: "iframe",
code: `<script id=start>
window.onmessage=e=>window.arg=e.data
Expand All @@ -97,10 +66,10 @@ hmm.storage = {
})
</script>`
},
"textpad.hmm":{
title:"TextPad",
type:"iframe",
code:`
"textpad.hmm": {
title: { en: "TextPad" },
type: "iframe",
code: `
<textarea id=t contenteditable=true style="
font-family:menlo,monospace;
border:1px solid #fff;
Expand Down Expand Up @@ -194,13 +163,13 @@ hmm.App = class {
this.filename = name
this.obj = hmm.storage.apps[name]
this.baritem = document.createElement("baritem")
this.baritem.innerText = this.title[0]
this.baritem.innerText = (this.title[hmm.storage.opts.lang] || this.filename.slice(0, -4))[0]
}
open(arg) {
var node = document.createElement("window")
var tb = document.createElement("taskbar")
tb.appendChild(document.createElement("span"))
tb.children[0].innerText = this.title
tb.children[0].innerText = this.title[hmm.storage.opts.lang] || this.filename.slice(0, -4)
var cls = document.createElement("close")
cls.innerText = "✕"
cls.onclick = (event) => {
Expand Down Expand Up @@ -255,15 +224,15 @@ hmm.App = class {
n.classList.add("win")
content.style.overflow = "hidden"
content.appendChild(n)
setTimeout(()=>{n.contentWindow.arg=arg},100)
setTimeout(() => { n.contentWindow.arg = arg }, 100)
}

node.appendChild(content)
var position = { x: 0, y: 0 }
interact(node).draggable({
allowFrom: "taskbar",
modifiers: [],
inertia:true,
inertia: true,
listeners: {
start(event) {
if (Math.abs(position.y - window.innerHeight) < 30) {
Expand Down Expand Up @@ -315,7 +284,7 @@ hmm.setMenu = () => {
let ap = hmm.storage.apps[app]
var el = document.createElement("t")
el.classList.add("menu-app")
el.innerText = ap.title
el.innerText = ap.title[hmm.storage.opts.lang] || app.slice(0, -4)
el.filename = app
el.onclick = e => {
hmm.openApp(e.target.filename);
Expand Down

0 comments on commit 989f28a

Please sign in to comment.