Skip to content

Commit 875bd0b

Browse files
committed
Load IPA Dictionary asynchronously
1 parent e966646 commit 875bd0b

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

dist/ipa_dict.json

+1-1
Large diffs are not rendered by default.

src/components/RunicEditor/index.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ function getSettings(obj: RunicEditor): VNode {
125125
}
126126

127127
const initialEnglishText = "Tunic\nSecret Legend!";
128+
const initialPhoneticText = "tunɪk\nsikɹət ɫɛdʒənd!";
128129

129130
export class RunicEditor extends Component<Props, State> {
130131
runeSVGElement?: RuneSVG;
@@ -133,7 +134,6 @@ export class RunicEditor extends Component<Props, State> {
133134
phoneticInput?: TextInput;
134135

135136
componentDidMount(): void {
136-
this.onEnglishChange(initialEnglishText);
137137
}
138138

139139
// Listeners
@@ -232,6 +232,7 @@ export class RunicEditor extends Component<Props, State> {
232232
placeholder="Type something here"
233233
name="text-input--phonetic"
234234
bindInput={this.onPhoneticChange}
235+
value={initialPhoneticText}
235236
spellcheck={false}
236237
/>
237238
</div>
@@ -244,7 +245,7 @@ export class RunicEditor extends Component<Props, State> {
244245
ref={(e) => (this.runeSVGElement = e)}
245246
interactive={false}
246247
displayPhonemes={false}
247-
phoneticText="sikɹət ɫɛdʒənd"
248+
phoneticText={initialPhoneticText}
248249
></RuneSVG>
249250
</div>
250251
<hr />

src/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ function addThemeListener() {
2828
mediaQuery.addEventListener("change", setTheme);
2929
}
3030

31-
async function setup() {
32-
await loadIPADict();
31+
function setup() {
32+
loadIPADict();
3333

3434
addThemeListener();
3535

src/ipa.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { symbolDataTable } from "./runeDataset";
2-
31
const IPADictURL = "./ipa_dict.json";
42

53
let IPADict: Record<string, string> = {};
@@ -8,13 +6,14 @@ export async function loadIPADict() {
86
// Load the dictionary
97
const response = await fetch(IPADictURL);
108
IPADict = await response.json();
9+
console.log("Loaded IPA Dictionary.")
1110
}
1211

1312
/**
1413
* Convert a word from English to Phonetic.
1514
*/
1615
export function translateWord(word: string): string | null {
17-
return word in IPADict ? IPADict[word][0].replace(/\s+/g, "") : null;
16+
return word in IPADict ? IPADict[word] : null;
1817
}
1918

2019
/**

0 commit comments

Comments
 (0)