Skip to content

Localize placeholder based on first language - #201

Merged
scottsfarley93 merged 6 commits into
version4from
localize-placeholder
Mar 18, 2019
Merged

scottsfarley93 merged 6 commits into
version4from
localize-placeholder

Conversation

@scottsfarley93

Copy link
Copy Markdown

Implements the change suggested in #150 by localizing the placeholder value based on the provided language option set in the constructor.

@scottsfarley93
scottsfarley93 changed the base branch from master to version4 March 13, 2019 21:33
@scottsfarley93 scottsfarley93 added this to the v4.0.0 milestone Mar 13, 2019
Comment thread lib/index.js Outdated
* Otherwise, if language is provided in options, then use the localized string of the first language if available
* Otherwise use the default
*/
getPlaceholderText: function(){

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this method be private?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to https://github.com/mapbox/mapbox-gl-geocoder/pull/198/files#r265396617 but I think it's better to re-gen the docs with each commit and include them.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Moved this to be a private method.

Comment thread lib/index.js
var localizedValue = localization.placeholder[language];
if (localizedValue) return localizedValue;
}
return 'Search';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could also lookup 'en' in localization.placeholder, but I don't think it really matters.

Comment thread lib/index.js
*
* If placeholder is provided in options, then use options.placeholder
* Otherwise, if language is provided in options, then use the localized string of the first language if available
* Otherwise use the default

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a JSDoc @returns here for completeness.

@katydecorah katydecorah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants