Semantic-ui: [Search] Remove English Text from Message Template

Created on 15 Jun 2015  路  10Comments  路  Source: Semantic-Org/Semantic-UI

Hi

I am trying to localise the search results, so that it will display "No results" in appropriate language. But, passing following doesn't do anything:

$(".search").search({ source: values, errors: { error: { noResults: 'Custom text ...'}} });
Enhancement stale

Most helpful comment

Any progress on this issue?

All 10 comments

Your settings object is just a little bit off. Here's the correct init.

$('.ui.search').search({
  source: values,
  error: {
    noResults: 'Custom text ...'
  }
});

I'm re-opening this since I have a similar issue and I can provide a test case:

source HTML:

<div class="ui search elements">
    <input type="text" class="prompt" name="element" value="">
    <div class="results elements" ></div>
</div>

Javascript code:

$('.ui.search').search({
  source: values,
  error: {
    noResults: 'Custom text ...'
  }
});

generated HTML when searching for non-existing value:

 <div class="ui search elements focus">
     <input type="text" class="prompt" name="element" value="" autocomplete="off">
     <div class="results elements transition visible">
         <div class="message empty">
             <div class="header">No Results</div>
             <div class="description">Custom text ...</div>
        </div>
    </div>
 </div>

I'd like to change the "No Results" message, not only the .description text. How can I do it?

thanks!

Can you provide a JSfiddle?

sure, here it is:

https://jsfiddle.net/xnfkLnwe/

I should probably move the string out of the template.
https://github.com/Semantic-Org/Semantic-UI/blob/next/src/definitions/modules/search.js#L1158

You could technicaly fix this now by overwriting $.fn.search.templates.message, but it'd probably be easier just to add a new string, and let the template pass in a header variable

Thank you so much!
Do you mean $.fn.search.settings.templates.message, am I right?

to future readers: here is a proof of concept of jlukic suggestion, until 2.0 will be released https://jsfiddle.net/xnfkLnwe/1/

Yes sorry I was jumping around issues a bit here.

Changing globally would be something like

$.fn.search.settings.templates.message = function(type, message) {
  html = '<div>some html</div>';
  return html;
};

You can also do this per element using

$('.ui.search')
  .search({
    templates: {
     message: function(type, message) {
       html = '<div>some html</div>';
       return html;
     }
    }
  })
;

btw, this line should have the arguments in the other order:

message: function(type, message) {}

should be

message: function(message, type) {}

if i'm not mistaken

Any progress on this issue?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

batata004 picture batata004  路  3Comments

mixerp picture mixerp  路  3Comments

zhaoyao91 picture zhaoyao91  路  3Comments

davialexandre picture davialexandre  路  3Comments

guilhermeblanco picture guilhermeblanco  路  3Comments