Skip to content

Commit 52a7a1f

Browse files
Merge pull request #343 from code-dot-org/i18n-object
Translating AI for Oceans
2 parents 2bf9809 + 23c70a9 commit 52a7a1f

File tree

11 files changed

+354
-166
lines changed

11 files changed

+354
-166
lines changed

i18n/oceans.json

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"fishvtrash-training-init1": "Garbage dumped in the water affects marine life. In this activity, you will program or train A.I. (artificial intelligence) to identify fish or trash. Let's clean up the ocean! Click anywhere on the screen to continue.",
3+
"fishvtrash-training-init2": "Let’s meet A.I.",
4+
"fishvtrash-training-init3": "A.I. does not know if an object is a fish or trash, but it can process images and identify patterns.",
5+
"fishvtrash-training-init4": "To program A.I., use the buttons to label an image as “Fish” or “Not Fish”. The training you provide will teach A.I. to recognize patterns on its own. Let’s get started!",
6+
"fishvtrash-training-pause1": "Seventeen billion pounds of plastic enter the ocean each year.",
7+
"fishvtrash-training-pause2": "You are programming or training A.I. with each click. Keep going.",
8+
"fishvtrash-training-pause3": "80% of ocean pollution comes from land debris and is estimated to cost $13 billion per year.",
9+
"fishvtrash-training-pause4": "A.I. learns from your choices. If you make “wrong” choices, A.I. will repeat your mistakes. Keep training.",
10+
"fishvtrash-training-pause5": "Great work! The more data you provide A.I., the more it learns. Keep training A.I. or continue when ready.",
11+
"fishvtrash-predicting-init1": "Now let’s see if A.I. knows what a “fish” looks like.",
12+
"fishvtrash-predicting-init2": "A.I. will analyze a random set of objects and label them based on your training.",
13+
"fishvtrash-predicting-init3": "Let’s go!",
14+
"fishvtrash-pond-init1": "Based on your training, here are some objects that A.I. identified as “fish”. How did A.I. do?",
15+
"fishvtrash-pond-recall": "Click here to switch between objects identified as “fish” and “not fish”.",
16+
"fishvtrash-pond-init2": "You can train A.I. more...",
17+
"fishvtrash-pond-init3": "...or Continue.",
18+
"creaturesvtrashdemo-predicting-init1": "So far, we trained A.I. to identify objects as either “fish” or “not fish”.",
19+
"creaturesvtrashdemo-predicting-init2": "What if this training data was used to decide what belonged in the water?",
20+
"creaturesvtrashdemo-predicting-init3": "What would happen to other sea creatures? Does our training approach cause unintended consequences?",
21+
"creaturesvtrashdemo-predicting-init4": "Let's see.",
22+
"creaturesvtrashdemo-predicting-pause1": "Did you notice that A.I. identified some sea creatures as “not fish”?",
23+
"creaturesvtrashdemo-predicting-pause2": "While these sea creatures are not fish, they do belong in the water.",
24+
"creaturesvtrashdemo-predicting-pause3": "A.I. only learns what we teach it.",
25+
"creaturesvtrashdemo-predicting-pause4": "Let’s train A.I. again.",
26+
"creaturesvtrash-training-init1": "Let’s teach A.I. to learn which objects should be in the water.",
27+
"creaturesvtrash-training-init2": "In the ocean, plastic debris can harm fish, seabirds, and marine mammals. Protecting seabirds and marine life is one of many reasons to keep the oceans clean.",
28+
"creaturesvtrash-training-init3": "The more training data you provide, the more A.I. learns. Keep training.",
29+
"creaturesvtrash-training-init4": "Marine plastic pollution has impacted at least 267 species worldwide, including 86% of all sea turtle species.",
30+
"creaturesvtrash-training-init5": "Keep training to teach A.I. what belongs in the water.",
31+
"creaturesvtrash-training-init6": "Great work! The more data you provide A.I., the better it will do. Keep training A.I. or continue when ready.",
32+
"creaturesvtrash-predicting-init1": "Do you think A.I. will now do a better job identifying what should be in the water? Let’s watch.",
33+
"creaturesvtrash-pond-init1": "Based on your training, here are some objects that A.I. identified as “belongs in water”. How did A.I. do?",
34+
"fishshort-words-init1": "Artificial intelligence and machine learning can be used to teach a computer new patterns.",
35+
"fishshort-words-init2": "Let’s teach A.I. a new word by showing it examples of that type of fish.",
36+
"fishshort-words-training-pause1": "Do you think A.I. has enough training data? You can click Continue to find out.",
37+
"fishshort-words-training-pause2": "Great work! Keep training A.I. or continue when ready.",
38+
"fishshort-predicting-init1": "With your training data, you have programmed A.I. to recognize “{word}” fish.",
39+
"fishshort-predicting-init2": "Let's see A.I. identify “{word}” fish.",
40+
"fishshort-pond-init1": "Based on your training, A.I. identified {n, plural,one {this} other {these}} fish as “{word}”. How did A.I. do? You can Train More if you want to improve the results.",
41+
"fishshort-pond-init2": "Click on the info button to see what A.I. learned.",
42+
"fishlong-words-init1": "Now let’s see if A.I. can learn a less obvious word.",
43+
"fishlong-words-init2": "Let’s teach A.I. a word that depends on your opinion. It is up to you to pick fish that match your word.",
44+
"fishlong-training-pause1": "Is it fair to use artificial intelligence to judge a fish by its looks? While AI might seem fair and neutral, its analysis comes from the training we provide. What unintended bias could this cause?",
45+
"fishlong-training-pause2": "More training data will help A.I. learn your word. Keep training.",
46+
"fishlong-training-pause3": "Each choice you make can help A.I. learn. Keep training.",
47+
"fishlong-training-pause4": "Do you think A.I. has enough training data? A.I. will do better with a lot of data. Continue when you think A.I. is ready.",
48+
"fishlong-training-many": "Wow. That's a lot of fish!",
49+
"fishlong-predicting-init1": "With your training data, you have programmed A.I. to recognize “{word}” fish.",
50+
"fishlong-predicting-init2": "Let’s see A.I. identify “{word}” fish.",
51+
"fishlong-pond-init1": "Based on your training, A.I. identified {n, plural,one {this} other {these}} fish as “{word}”. How did A.I. do?",
52+
"fishlong-pond-init2": "You can Train More if you want to improve the results.",
53+
"fishlong-pond-init3": "Or you can teach A.I. a new word by choosing New Word.",
54+
"didYouKnow": "Did you know?",
55+
"continue": "Continue",
56+
"areYouSure": "Are you sure?",
57+
"eraseWarning": "Erasing A.I.'s data will permanently delete all training. Is that what you want to do?",
58+
"erase": "Erase",
59+
"cancel": "Cancel",
60+
"yes": "Yes",
61+
"no": "No",
62+
"notWord": "Not {word}",
63+
"run": "Run",
64+
"mostImportantParts": "These were the most important fish parts:",
65+
"clickIndividualFish": "Click individual fish to see their information.",
66+
"mostImportantPartsInDetermining": "These were the most important fish parts in determining whether this fish was",
67+
"or": "or",
68+
"newWord": "New Word",
69+
"finish": "Finish",
70+
"trainMore": "Train More",
71+
"wordQuestionShort": "What type of fish do you want to train A.I. to detect?",
72+
"wordQuestionLong": "Choose a new word to teach A.I.",
73+
"isThisFish": "Is this fish {word}?",
74+
"isThisAFish": "Is this a fish?",
75+
"doesThisBelongInWater": "Does this belong in the water?",
76+
"fish": "Fish",
77+
"waterCreature": "Water creature",
78+
"blue": "Blue",
79+
"green": "Green",
80+
"red": "Red",
81+
"circular": "Circular",
82+
"rectangular": "Rectangular",
83+
"triangular": "Triangular",
84+
"angry": "Angry",
85+
"awesome": "Awesome",
86+
"delicious": "Delicious",
87+
"endangered": "Endangered",
88+
"fast": "Fast",
89+
"fierce": "Fierce",
90+
"fun": "Fun",
91+
"glitchy": "Glitchy",
92+
"happy": "Happy",
93+
"hungry": "Hungry",
94+
"playful": "Playful",
95+
"scary": "Scary",
96+
"silly": "Silly",
97+
"spooky": "Spooky",
98+
"wild": "Wild",
99+
"dorsalFins": "dorsal fin",
100+
"pectoralFinsFront": "pectoral fins",
101+
"tails": "tail",
102+
"bodies": "body",
103+
"scales": "scales",
104+
"eyes": "eyes",
105+
"mouths": "mouth",
106+
"colors": "colors"
107+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"@fortawesome/fontawesome-svg-core": "^1.2.25",
9898
"@fortawesome/free-solid-svg-icons": "^5.11.2",
9999
"@fortawesome/react-fontawesome": "^0.1.7",
100+
"messageformat": "^1.1.0",
100101
"react-typist": "^2.0.5"
101102
},
102103
"files": [

src/oceans/helpers.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,6 @@ export const colorForFishPart = (palette, part) => {
6666
}
6767
};
6868

69-
export const friendlyNameForFishPart = part => {
70-
const friendlyNamesForFishParts = {
71-
dorsalFins: 'dorsal fin',
72-
pectoralFinsFront: 'pectoral fins',
73-
tails: 'tail',
74-
bodies: 'body',
75-
scales: 'scales',
76-
eyes: 'eyes',
77-
mouths: 'mouth',
78-
colors: 'color'
79-
};
80-
81-
return friendlyNamesForFishParts[part];
82-
};
83-
8469
export const randomInt = (min, max) => {
8570
min = Math.ceil(min);
8671
max = Math.floor(max);

src/oceans/i18n.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import data from '../../i18n/oceans.json';
2+
import MessageFormat from 'messageformat'
3+
4+
let messages;
5+
6+
const initI18n = (i18n = {}) => {
7+
// For now, use English pluralization rules.
8+
const mf = new MessageFormat('en');
9+
messages = {...mf.compile(data), ...i18n};
10+
};
11+
12+
const t = (key, options) => {
13+
if (!messages) {
14+
throw "I18n must be initialized before calling t";
15+
}
16+
return messages[key](options);
17+
};
18+
19+
export default {
20+
initI18n,
21+
t
22+
};

src/oceans/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function initDemoPage() {
3030
canvas,
3131
backgroundCanvas,
3232
playSound: sounds.play.bind(sounds),
33-
registerSound: sounds.register.bind(sounds),
33+
registerSound: sounds.register.bind(sounds)
3434
});
3535
}
3636

src/oceans/init.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {setInitialState, setSetStateCallback} from './state';
77
import {render as renderCanvas} from './renderer';
88
import modeHelpers from './modeHelpers';
99
import soundLibrary from './models/soundLibrary';
10+
import I18n from './i18n';
1011

1112
//
1213
// Required in options:
@@ -26,6 +27,8 @@ export const initAll = function(options) {
2627

2728
soundLibrary.loadSounds();
2829

30+
I18n.initI18n(options.i18n);
31+
2932
// Set initial state for UI elements.
3033
setInitialState({
3134
currentMode: Modes.Loading,

0 commit comments

Comments
 (0)