Skip to content

Commit

Permalink
Add demo webpack starter with basic customer and provider usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Дмитрий Коваленко authored and Дмитрий Коваленко committed Jun 23, 2018
1 parent 74c18e8 commit 6f534ef
Show file tree
Hide file tree
Showing 15 changed files with 6,900 additions and 366 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ typings/
.next

build/
.DS_Store
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Используйте IntelliSense, чтобы узнать о возможных атрибутах.
// Наведите указатель мыши, чтобы просмотреть описания существующих атрибутов.
// Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Запустить программу",
"program": "${workspaceFolder}/index.js",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": [
"${workspaceFolder}/../build/**/*.js"
]
}
]
}
22 changes: 22 additions & 0 deletions demo/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react';
import { hot } from 'react-hot-loader'
import Translate from '../src/Translate';
import NameSpaceProvider from '../src/NamespaceProvider';

interface AppProps { }

const App: React.SFC<AppProps> = (props) => {
return (
<div>
<div> Here would be some examples </div>
<Translate> hi </Translate>

<NameSpaceProvider ns="specificNs">
<Translate> hi </Translate>
<Translate> something-specific </Translate>
</NameSpaceProvider>
</div>
)
};

export default hot(module)(App)
13 changes: 13 additions & 0 deletions demo/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react'
import * as ReactDom from 'react-dom'

import App from './App'
import I18NextProvider from '../src/I18NextProvider';
import i18n from './services/i18n';

ReactDom.render(
<I18NextProvider i18n={i18n}>
<App />
</I18NextProvider>,
document.getElementById('root')
)
18 changes: 18 additions & 0 deletions demo/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

<title> Demo page </title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>

<div id="root"></div>
</body>
</html>
17 changes: 17 additions & 0 deletions demo/services/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as i18n from 'i18next';
import * as translations from '../translations.json';

i18n
.init({
resources: translations,
fallbackLng: 'ru',
debug: true,
// have a comnpmmon namespace used around the full app
ns: ['common'],
defaultNS: 'common',
fallbackNS: 'common',

keySeparator: false, // we use content as keys
});

export default i18n;
18 changes: 18 additions & 0 deletions demo/translations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"en": {
"common": {
"hi": "hi"
},
"specificNs": {
"somesthing_specific": "somesthing_specific"
}
},
"ru": {
"common": {
"hi": "Привет"
},
"specificNs": {
"somesthing_specific": "что-то специфичное"
}
}
}
Loading

0 comments on commit 6f534ef

Please sign in to comment.