Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
d3b8c208
Commit
d3b8c208
authored
Oct 15, 2015
by
Ray Schamp
Committed by
Matthew Taylor
Oct 15, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the language dropdown, it almost works
parent
aaf263f9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
196 additions
and
2 deletions
+196
-2
server/proxies.json
server/proxies.json
+3
-1
src/components/footer/footer.jsx
src/components/footer/footer.jsx
+36
-0
src/components/footer/footer.scss
src/components/footer/footer.scss
+5
-1
src/components/forms/select.jsx
src/components/forms/select.jsx
+24
-0
src/components/forms/select.scss
src/components/forms/select.scss
+9
-0
src/components/languagechooser/languagechooser.jsx
src/components/languagechooser/languagechooser.jsx
+44
-0
src/components/languagechooser/languagechooser.scss
src/components/languagechooser/languagechooser.scss
+3
-0
src/components/languagechooser/languages.json
src/components/languagechooser/languages.json
+72
-0
No files found.
server/proxies.json
View file @
d3b8c208
...
...
@@ -6,7 +6,9 @@
"/accounts/"
,
"/csrf_token/"
,
"/get_image/"
,
"/session/"
"/i18n/"
,
"/session/"
,
"/site-api/"
]
}
]
src/components/footer/footer.jsx
View file @
d3b8c208
var
React
=
require
(
'
react
'
);
var
log
=
require
(
'
../../log.js
'
);
var
Api
=
require
(
'
../../mixins/api.jsx
'
);
var
CookieMixinFactory
=
require
(
'
../../mixins/cookieMixinFactory.jsx
'
);
var
LanguageChooser
=
require
(
'
../languagechooser/languagechooser.jsx
'
);
require
(
'
./footer.scss
'
);
var
Footer
=
React
.
createClass
({
type
:
'
Footer
'
,
mixins
:
[
Api
,
// Provides useScratchlanguage
CookieMixinFactory
(
'
scratchlanguage
'
,
'
/site-api/i18n/set-preferred-language/
'
)
],
getInitialState
:
function
()
{
return
{
language
:
'
en
'
};
},
componentDidMount
:
function
()
{
this
.
updateLanguage
();
},
updateLanguage
:
function
()
{
this
.
useScratchlanguage
(
function
(
err
,
language
)
{
if
(
err
)
return
log
.
error
(
err
);
this
.
setState
({
language
:
language
});
}.
bind
(
this
));
},
handleSetLanguage
:
function
(
e
)
{
if
(
e
)
e
.
preventDefault
();
this
.
api
({
host
:
''
,
uri
:
'
/i18n/setlang/
'
},
function
(
err
,
body
)
{
if
(
body
)
this
.
updateLanguage
();
}.
bind
(
this
));
},
render
:
function
()
{
return
(
<
div
className=
"inner"
>
...
...
@@ -52,6 +86,8 @@ var Footer = React.createClass({
</
dl
>
</
div
>
<
LanguageChooser
onSetLanguage=
{
this
.
handleSetLanguage
}
choice=
{
this
.
state
.
language
}
/>
<
div
className=
"copyright"
>
<
p
>
Scratch is a project of the Lifelong Kindergarten Group at the MIT Media Lab
</
p
>
</
div
>
...
...
src/components/footer/footer.scss
View file @
d3b8c208
...
...
@@ -5,6 +5,7 @@
background-color
:
$ui-gray
;
padding
:
10px
0
;
color
:
$type-gray
;
font-size
:
.85rem
;
.lists
{
display
:
flex
;
...
...
@@ -18,7 +19,6 @@
width
:
130pt
;
vertical-align
:
top
;
text-align
:
left
;
font-size
:
.85rem
;
}
dt
{
...
...
@@ -42,4 +42,8 @@
font-size
:
.7rem
;
}
}
.language-chooser
{
text-align
:
center
;
}
}
src/components/forms/select.jsx
0 → 100644
View file @
d3b8c208
var
React
=
require
(
'
react
'
);
var
classNames
=
require
(
'
classnames
'
);
require
(
'
./select.scss
'
);
var
Select
=
React
.
createClass
({
type
:
'
Select
'
,
propTypes
:
{
},
render
:
function
()
{
var
classes
=
classNames
(
'
select
'
,
this
.
props
.
className
);
return
(
<
select
{
...
this
.
props
}
className=
{
classes
}
>
{
this
.
props
.
children
}
</
select
>
);
}
});
module
.
exports
=
Select
;
src/components/forms/select.scss
0 → 100644
View file @
d3b8c208
@import
"../../colors"
;
.select
{
background-color
:
$ui-white
;
width
:
220px
;
height
:
28px
;
line-height
:
28px
;
font-size
:
1em
;
}
src/components/languagechooser/languagechooser.jsx
0 → 100644
View file @
d3b8c208
var
classNames
=
require
(
'
classnames
'
);
var
React
=
require
(
'
react
'
);
var
Select
=
require
(
'
../forms/select.jsx
'
);
require
(
'
./languagechooser.scss
'
);
var
LanguageChooser
=
React
.
createClass
({
type
:
'
LanguageChooser
'
,
propTypes
:
{
choice
:
React
.
PropTypes
.
string
,
languages
:
React
.
PropTypes
.
object
},
getDefaultProps
:
function
()
{
return
{
choice
:
'
en
'
,
languages
:
require
(
'
./languages.json
'
)
};
},
render
:
function
()
{
var
classes
=
classNames
(
'
language-chooser
'
,
this
.
props
.
className
);
return
(
<
form
ref=
"languageForm"
method=
"post"
action=
"/i18n/setlang/"
{
...
this
.
props
}
className=
{
classes
}
onSubmit=
{
this
.
props
.
onSetLanguage
}
>
<
Select
name=
"language"
value=
{
this
.
props
.
choice
}
onChange=
{
this
.
props
.
onSetLanguage
}
>
{
Object
.
keys
(
this
.
props
.
languages
).
map
(
function
(
value
)
{
return
<
option
value=
{
value
}
key=
{
value
}
>
{
this
.
props
.
languages
[
value
]
}
</
option
>;
}.
bind
(
this
))
}
</
Select
>
</
form
>
);
}
});
module
.
exports
=
LanguageChooser
;
src/components/languagechooser/languagechooser.scss
0 → 100644
View file @
d3b8c208
.language-chooser
{
}
src/components/languagechooser/languages.json
0 → 100644
View file @
d3b8c208
{
"en"
:
"English"
,
"an"
:
"Aragonés"
,
"ast"
:
"Asturianu"
,
"id"
:
"Bahasa Indonesia"
,
"ms"
:
"Bahasa Melayu"
,
"ca"
:
"Català"
,
"cs"
:
"Česky"
,
"cy"
:
"Cymraeg"
,
"da"
:
"Dansk"
,
"fa-af"
:
"Dari"
,
"de"
:
"Deutsch"
,
"yum"
:
"Edible Scratch"
,
"et"
:
"Eesti"
,
"eo"
:
"Esperanto"
,
"es"
:
"Español"
,
"eu"
:
"Euskara"
,
"fr"
:
"Français"
,
"fr-ca"
:
"Français (Canada)"
,
"ga"
:
"Gaeilge"
,
"gd"
:
"Gàidhlig"
,
"gl"
:
"Galego"
,
"hr"
:
"Hrvatski"
,
"is"
:
"Íslenska"
,
"it"
:
"Italiano"
,
"rw"
:
"Kinyarwanda"
,
"ku"
:
"Kurdî"
,
"la"
:
"Latina"
,
"lv"
:
"Latviešu"
,
"lt"
:
"Lietuvių"
,
"hu"
:
"Magyar"
,
"mt"
:
"Malti"
,
"cat"
:
"Meow"
,
"nl"
:
"Nederlands"
,
"nb"
:
"Norsk Bokmål"
,
"pl"
:
"Polski"
,
"pt"
:
"Português"
,
"pt-br"
:
"Português Brasileiro"
,
"ro"
:
"Română"
,
"sc"
:
"Sardu"
,
"sk"
:
"Slovenčina"
,
"sl"
:
"Slovenščina"
,
"fi"
:
"suomi"
,
"sv"
:
"Svenska"
,
"nai"
:
"Tepehuan"
,
"vi"
:
"Tiếng Việt"
,
"tr"
:
"Türkçe"
,
"ab"
:
"Аҧсшәа"
,
"ar"
:
"العربية"
,
"bg"
:
"Български"
,
"el"
:
"Ελληνικά"
,
"fa"
:
"فارسی"
,
"he"
:
"עִבְרִית"
,
"hi"
:
"हिन्दी"
,
"hy"
:
"Հայերեն"
,
"ja"
:
"日本語"
,
"ja-hr"
:
"にほんご"
,
"km"
:
"សំលៀកបំពាក"
,
"kn"
:
"ಭಾಷೆ-ಹೆಸರು"
,
"ko"
:
"한국어"
,
"mk"
:
"Македонски"
,
"ml"
:
"മലയാളം"
,
"mn"
:
"Монгол хэл"
,
"mr"
:
"मराठी"
,
"my"
:
"မြန်မာဘာသာ"
,
"ru"
:
"Русский"
,
"sr"
:
"Српски"
,
"th"
:
"ไทย"
,
"uk"
:
"Українська"
,
"zh-cn"
:
"简体中文"
,
"zh-tw"
:
"正體中文"
}
\ No newline at end of file
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