-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quick hack to try out the translations API.
- Loading branch information
1 parent
328493a
commit 8ca48ec
Showing
6 changed files
with
43 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import apiClient from 'panoptes-client/lib/api-client'; | ||
|
||
const translations = { | ||
strings: {}, | ||
load: (translated_type, translated_id, language) => { | ||
delete translations.strings[translated_type]; | ||
return apiClient | ||
.type('translations') | ||
.get({ translated_type, translated_id, language }) | ||
.then(([translation]) => { | ||
translations.strings[translated_type] = translation.strings; | ||
}) | ||
.catch(error => { | ||
console.log(error.status); | ||
switch (error.status) { | ||
case 404: | ||
translations.strings[translated_type] = {}; | ||
break; | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
export default translations; |