Skip to content

Commit

Permalink
Improved documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
benatespina committed Dec 28, 2018
1 parent 19b6761 commit 3dad76a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ReactI18nRouting
> 🌐 Abstraction layer over react-router to create i18n routes easily
> 🌐 Abstraction layer over React-Router to create i18n routes easily
[![npm version](https://img.shields.io/npm/v/@foes/react-i18n-routing.svg?style=flat-square)](https://www.npmjs.com/package/@foes/react-i18n-routing)
[![Build Status](http://img.shields.io/travis/FriendsOfECMAScript/ReactI18nRouting/master.svg?style=flat-square)](https://travis-ci.org/FriendsOfECMAScript/ReactI18nRouting)
Expand All @@ -17,11 +17,11 @@

There are robust solutions that they have become in standard solutions to usual problems in *React* ecosystem such as
**routing** with *React-Router* and its all related packages.
These libraries make our life more easy building apps but, what happens when we need to translate our routing system? In this case, we think that we need some other library over *React-Router* to join with any i18n
system so, we have created the ReactI18nRouting.
These libraries make our life more easy building apps but, what happens when we need to translate our routing system? In this case, we think that we need some other library over *React-Router* to join with any **i18n**
system so, we have created the *ReactI18nRouting*.

This library aims to provide all the needed to make the internationalization of the routes as easy as possible.
We truly trust in the **Single Responsibility Pattern** so, we have designed the library following the UNIX popular
We truly trust in the *Single Responsibility Pattern* so, we have designed the library following the UNIX popular
concept:<br>*DOTADIW, or "Do One Thing and Do It Well"*.

## 📟 Install
Expand Down Expand Up @@ -51,7 +51,8 @@ $ yarn cs # or npm run cs
```
There is also a policy for contributing to this library. Pull requests must be explained step by step to make the
review process easy in order to accept and merge them. New methods or code improvements must come paired with
tests. We are using [Jest][4] test framework for that purpose.
tests. We are using [Jest][4] test framework for that purpose; and over that, to make our life easier, we are using
[React Testing Library][5].
```bash
$ yarn test # or npm test
```
Expand All @@ -72,3 +73,4 @@ This library is created and maintained by:
[2]: http://eslint.org/
[3]: https://prettier.io/
[4]: https://facebook.github.io/jest/
[5]: https://github.com/kentcdodds/react-testing-library
11 changes: 2 additions & 9 deletions docs/basic_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ First of all, we have to define our routes with their translations:
export const HOME = 'home';
export const PAGE = 'page';
export const POST = 'post';
export const ARRAY_PATH_ROUTE = 'array-path-route';

export default {
[HOME]: '/',
Expand All @@ -27,12 +26,6 @@ export default {
eu: '/orrialdea/**',
fr: '/page/**',
},
[ARRAY_PATH_ROUTE]: {
en: ['/page', '/news'],
es: ['/pagina', '/noticia'],
eu: ['/orrialdea', '/albistea'],
fr: ['/page', '/nouvelles'],
},
};
```

Expand Down Expand Up @@ -79,15 +72,14 @@ import createHistory from 'history/createBrowserHistory';
import routes from './routing/config';

const history = createHistory();
const renderMethod = module.hot ? ReactDOM.render : ReactDOM.hydrate;

const languageStrategy = defaultUnprefixed({
routes: routes,
locales: ['eu', 'es', 'en', 'fr'],
defaultLocale: 'es'
});

const renderMethod = module.hot ? ReactDOM.render : ReactDOM.hydrate;

renderMethod(
<I18nRoutingProvider
defaultTranslatedRoutes={{es: '/es', en: '/'}}
Expand All @@ -104,4 +96,5 @@ renderMethod(
```

- In order to need more info about language strategies check [this guide](language_strategies.md).
- If you want to learn how to create React-Router link components with translation capabilities check [this guide](react_router_components.md).
- Back to the [index](index.md).
4 changes: 4 additions & 0 deletions docs/language_strategies.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Prefixes all paths with locales but the locale set as default.

```javascript
import {defaultUnprefixed} from '@foes/react-i18n-routing';
import routes from './routing/config';

const locales = ['eu', 'es', 'en', 'fr'];
const defaultLocale = 'eu';
Expand All @@ -30,6 +31,7 @@ Based on domain resolves current locale.

```javascript
import {subdomainBased} from '@foes/react-i18n-routing';
import routes from './routing/config';

const locales = ['eu', 'es', 'en', 'fr'];
const defaultLocale = 'eu';
Expand All @@ -48,6 +50,8 @@ const languageStrategy = subdomainBased({
});
```

- [Back to the first chapter](basic_usage.md) if you want to configure this library in your React app.
- If you want to learn how to create React-Router link components with translation capabilities check [this guide](react_router_components.md).
- Back to the [index](index.md).

[1]: https://developer.mozilla.org/en-US/docs/Web/API/Location
2 changes: 2 additions & 0 deletions docs/react_router_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ import {FormattedLink, FormattedNavLink, FormattedRedirect} from '@foes/react-i1
<FormattedRedirect name="route_name" params={{param1: 'value'}}/>
```

- [Back to the first chapter](basic_usage.md) if you want to configure this library in your React app.
- In order to need more info about language strategies check [this guide](language_strategies.md).
- Back to the [index](index.md).

0 comments on commit 3dad76a

Please sign in to comment.