Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update docs when ui is auto included
- Loading branch information
Showing
8 changed files
with
118 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,53 @@ | ||
import {GoToDocsButton} from "../component/GoToDocsButton"; | ||
import { GoToDocsButton } from '../component/GoToDocsButton'; | ||
|
||
<GoToDocsButton href="https://tolgee.io/docs/web/using_with_npm/installation" style={{ float: "right" }} /> | ||
<GoToDocsButton | ||
href="https://tolgee.io/docs/web/using_with_npm/installation" | ||
style={{ float: 'right' }} | ||
/> | ||
|
||
To use Tolgee with NPM, please visit [docs](https://tolgee.io/docs/web/using_with_npm/installation). | ||
|
||
It works fine with Webpack or Rollup projects! ;) | ||
|
||
## Install packages | ||
|
||
```shell-session | ||
npm install @tolgee/core @tolgee/ui --save | ||
npm install @tolgee/core @tolgee/ui | ||
``` | ||
|
||
## Create Tolgee instance | ||
|
||
```javascript | ||
import {Tolgee} from "@tolgee/ui"; | ||
import {UI} from "@tolgee/ui"; | ||
import { Tolgee } from '@tolgee/ui'; | ||
import { UI } from '@tolgee/ui'; | ||
|
||
const tg = new Tolgee({ | ||
// ############################################################ | ||
// ## you should never leak your API key ## | ||
// ## remove it in for production publicly accessible site ## | ||
// ############################################################ | ||
apiKey: "{{{apiKey}}}", | ||
apiUrl: "{{{apiUrl}}}", | ||
ui: UI | ||
apiKey: '{{{apiKey}}}', | ||
apiUrl: '{{{apiUrl}}}', | ||
ui: UI, | ||
}); | ||
|
||
tg.run(); | ||
``` | ||
|
||
## Do stuff when Tolgee is loaded (optional) | ||
|
||
```javascript | ||
tg.run().then(() => { | ||
document.getElementById("loading").style.display = "none"; | ||
}) | ||
document.getElementById('loading').style.display = 'none'; | ||
}); | ||
``` | ||
|
||
## Use Tolgee! | ||
|
||
```javascript | ||
pg.onLangChange.subscribe(() => { | ||
pg.translate("tolgee_example_title", undefined, true).then(t => { | ||
document.title = t; //change the document title when language changes! | ||
}); | ||
pg.translate('tolgee_example_title', undefined, true).then((t) => { | ||
document.title = t; //change the document title when language changes! | ||
}); | ||
}); | ||
``` |
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
Oops, something went wrong.