Skip to content

Commit

Permalink
add more translate docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ssetem committed Jan 15, 2016
1 parent 17a3d24 commit 93612e6
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 25 deletions.
3 changes: 3 additions & 0 deletions docs/components/basics/search-box.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ class App extends SearchkitComponent<any, any> {
- `mod` *(string)*: Optional. A custom BEM container class.
- `translations` *(Object)*: An object of translations you wish to override. For more information on translations see [translate](../../core/translate.md) page.

## Translations
- `searchbox.placeholder` - "Search"

## Demo
[](codepen://searchkit/zrNrGW?height=800&theme=0)
6 changes: 6 additions & 0 deletions docs/components/metadata/stats.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ You can override the default display for HitsStats by overriding the renderText
- `getHitCount` returns the number of hits.
- `getTime` returns the time taken for the query.
- `getResults` returns the results object.

## Props
- `translations` *(Object)*: An object of translations you wish to override. For more information on translations see [translate](../../core/translate.md) page.

## Translations
- `hitstats.results_found` - "results found"
4 changes: 4 additions & 0 deletions docs/components/navigation/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ class App extends SearchkitComponent<any, any> {

## Props
- `translations` *(Object)*: An object of translations you wish to override. For more information on translations see [translate](../../core/translate.md) page.

## Translations
- `pagination.previous` - Previous
- `pagination.next` - Next
5 changes: 5 additions & 0 deletions docs/components/navigation/refinement-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class App extends SearchkitComponent<any, any> {
- `operator` *('AND'|'OR')*: If you filter on a and b with OR, results with either the value a or b will match. If you select a and b, results will show which have both a and b.
- `translations` *(Object)*: An object of translations you wish to override. For more information on translations see [translate](../../core/translate.md) page.

## Translations
- `facets.view_more` - View more
- `facets.view_less` - View less
- `facets.view_all` - View all


## Demo
[](codepen://searchkit/zrNrzL?height=800&theme=0)
2 changes: 2 additions & 0 deletions docs/components/navigation/reset.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class App extends SearchkitComponent<any, any> {
## Props
- `translations` *(Object)*: An object of translations you wish to override. For more information on translations see [translate](../../core/translate.md) page.

## Translations
- `reset.clear_all` - Clear All Filters

## Extending Component

Expand Down
20 changes: 20 additions & 0 deletions docs/core/Translate.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,23 @@ You can pass any component an object of translations you wish to override. Examp
```jsx
<SearchBox translations={{"searchbox.placeholder":"search movies"}} autofocus={true} searchOnChange={true} queryFields={["actors^1","type^2","languages","title^5", "genres^2"]}/>
```

## List of all translation overrides with their defaults

### ResetFilters
- `reset.clear_all` - Clear All Filters

### RefinementListFilter
- `facets.view_more` - View more
- `facets.view_less` - View less
- `facets.view_all` - View all

### HitStats
- `hitstats.results_found` - "results found"

### Pagination
- `pagination.previous` - Previous
- `pagination.next` - Next

### Searchbox
- `searchbox.placeholder` - "Search"

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/src/components/search/hits-stats/src/HitsStats.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/components/search/hits-stats/src/HitsStats.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/components/search/hits-stats/test/HitsStatsSpec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface ResetFiltersProps extends SearchkitComponentProps {
export class ResetFilters extends SearchkitComponent<ResetFiltersProps, any> {

static translations:any = {
"ClearAllFilters":"Clear all filters"
"reset.clear_all":"Clear all filters"
}
translations = ResetFilters.translations

Expand Down Expand Up @@ -46,7 +46,7 @@ export class ResetFilters extends SearchkitComponent<ResetFiltersProps, any> {
var block = this.bemBlocks.container

return (
<div className={block("reset")}>{this.translate("ClearAllFilters")}</div>
<div className={block("reset")}>{this.translate("reset.clear_all")}</div>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ describe("Reset Filter tests", () => {
beforeEach(() => {

this.searchkit = new SearchkitManager("localhost:9200", {useHistory:true})
this.searchkit.translateFunction = (key)=> {
return {
"ClearAllFilters":"reset filters"
}[key]
}

this.createWrapper = () => {
this.wrapper = mount(
<ResetFilters searchkit={this.searchkit} />
<ResetFilters searchkit={this.searchkit} translations={{"reset.clear_all":"reset filters"}}/>
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/search/hits-stats/src/HitsStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface HitsStatsProps extends SearchkitComponentProps {
export class HitsStats extends SearchkitComponent<HitsStatsProps, any> {

static translations:any = {
"ResultsFound":"results found"
"hitstats.results_found":"results found"
}
translations = HitsStats.translations

Expand All @@ -40,7 +40,7 @@ export class HitsStats extends SearchkitComponent<HitsStatsProps, any> {
renderText() {
return (
<div className={this.bemBlocks.container("info")} data-qa="info">
{this.getHitCount()} {this.translate("ResultsFound")}
{this.getHitCount()} {this.translate("hitstats.results_found")}
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/hits-stats/test/HitsStatsSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("HitsStats tests", () => {
this.createWrapper = () => {

this.wrapper = mount(
<HitsStats searchkit={this.searchkit} translations={{"ResultsFound":"movies found"}} />
<HitsStats searchkit={this.searchkit} translations={{"hitstats.results_found":"movies found"}} />
);

}
Expand Down

0 comments on commit 93612e6

Please sign in to comment.