diff options
author | Dessalines <dessalines@users.noreply.github.com> | 2019-08-09 17:14:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-09 17:14:43 -0700 |
commit | 536c3f491546b4546f43a46e7a1a699ca9ac2934 (patch) | |
tree | f080c86e51b9660560ac493cb7f6d9676ea12fbe /ui/src/components/communities.tsx | |
parent | 5a1e8aa645c9f0898e765b45c2f362308292db26 (diff) |
Adding support for internationalization / i18n (#189)
* Still not working
* Starting to work on internationalization
* Main done.
* i18n translations first pass.
* Localization testing mostly done.
* Second front end pass.
* Added a few more translations.
* Adding back end translations.
Diffstat (limited to 'ui/src/components/communities.tsx')
-rw-r--r-- | ui/src/components/communities.tsx | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx index c4efe1fb..49b982dc 100644 --- a/ui/src/components/communities.tsx +++ b/ui/src/components/communities.tsx @@ -5,6 +5,8 @@ import { retryWhen, delay, take } from 'rxjs/operators'; import { UserOperation, Community, ListCommunitiesResponse, CommunityResponse, FollowCommunityForm, ListCommunitiesForm, SortType } from '../interfaces'; import { WebSocketService } from '../services'; import { msgOp } from '../utils'; +import { i18n } from '../i18next'; +import { T } from 'inferno-i18next'; declare const Sortable: any; @@ -26,12 +28,12 @@ export class Communities extends Component<any, CommunitiesState> { super(props, context); this.state = this.emptyState; this.subscription = WebSocketService.Instance.subject - .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) - .subscribe( - (msg) => this.parseMessage(msg), + .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) + .subscribe( + (msg) => this.parseMessage(msg), (err) => console.error(err), () => console.log('complete') - ); + ); this.refetch(); @@ -46,7 +48,7 @@ export class Communities extends Component<any, CommunitiesState> { } componentDidMount() { - document.title = `Communities - ${WebSocketService.Instance.site.name}`; + document.title = `${i18n.t('communities')} - ${WebSocketService.Instance.site.name}`; } // Necessary for back button for some reason @@ -64,17 +66,17 @@ export class Communities extends Component<any, CommunitiesState> { {this.state.loading ? <h5 class=""><svg class="icon icon-spinner spin"><use xlinkHref="#icon-spinner"></use></svg></h5> : <div> - <h5>List of communities</h5> + <h5><T i18nKey="list_of_communities">#</T></h5> <div class="table-responsive"> <table id="community_table" class="table table-sm table-hover"> <thead class="pointer"> <tr> - <th>Name</th> - <th class="d-none d-lg-table-cell">Title</th> - <th>Category</th> - <th class="text-right">Subscribers</th> - <th class="text-right d-none d-lg-table-cell">Posts</th> - <th class="text-right d-none d-lg-table-cell">Comments</th> + <th><T i18nKey="name">#</T></th> + <th class="d-none d-lg-table-cell"><T i18nKey="title">#</T></th> + <th><T i18nKey="category">#</T></th> + <th class="text-right"><T i18nKey="subscribers">#</T></th> + <th class="text-right d-none d-lg-table-cell"><T i18nKey="posts">#</T></th> + <th class="text-right d-none d-lg-table-cell"><T i18nKey="comments">#</T></th> <th></th> </tr> </thead> @@ -89,8 +91,8 @@ export class Communities extends Component<any, CommunitiesState> { <td class="text-right d-none d-lg-table-cell">{community.number_of_comments}</td> <td class="text-right"> {community.subscribed ? - <span class="pointer btn-link" onClick={linkEvent(community.id, this.handleUnsubscribe)}>Unsubscribe</span> : - <span class="pointer btn-link" onClick={linkEvent(community.id, this.handleSubscribe)}>Subscribe</span> + <span class="pointer btn-link" onClick={linkEvent(community.id, this.handleUnsubscribe)}><T i18nKey="unsubscribe">#</T></span> : + <span class="pointer btn-link" onClick={linkEvent(community.id, this.handleSubscribe)}><T i18nKey="subscribe">#</T></span> } </td> </tr> @@ -109,9 +111,9 @@ export class Communities extends Component<any, CommunitiesState> { return ( <div class="mt-2"> {this.state.page > 1 && - <button class="btn btn-sm btn-secondary mr-1" onClick={linkEvent(this, this.prevPage)}>Prev</button> + <button class="btn btn-sm btn-secondary mr-1" onClick={linkEvent(this, this.prevPage)}><T i18nKey="prev">#</T></button> } - <button class="btn btn-sm btn-secondary" onClick={linkEvent(this, this.nextPage)}>Next</button> + <button class="btn btn-sm btn-secondary" onClick={linkEvent(this, this.nextPage)}><T i18nKey="next">#</T></button> </div> ); } @@ -165,7 +167,7 @@ export class Communities extends Component<any, CommunitiesState> { console.log(msg); let op: UserOperation = msgOp(msg); if (msg.error) { - alert(msg.error); + alert(i18n.t(msg.error)); return; } else if (op == UserOperation.ListCommunities) { let res: ListCommunitiesResponse = msg; |