title: Dynamic setting language in Golang web framework Iris
body: <blockquote>
    <p>I have these language files:</p>
  </blockquote>
  
  <pre><code>locales/
      en-US/
          a.yaml
          b.yaml
      zh-CN/
          a.yaml
          b.yaml
      DA/
          a.yaml
          b.yaml
  </code></pre>
  
  <blockquote>
    <p>set default  language:</p>
  </blockquote>
  
  <pre><code>app.I18n.SetDefault("en-US")
  </code></pre>
  
  <blockquote>
    <p>How to set language dynamically according to <code>l</code> parameter:</p>
  </blockquote>
  
  <pre><code>www.sete.com/xx/xxx?l=en =&gt; set en-US
  www.sete.com/xx/xxx?l=cn =&gt; set zh-CN
  www.sete.com/xx/xxx?l=da =&gt; set DA
  
  www.sete.com/xx/xxx?l=NotFound =&gt; default en-US
  </code></pre>
  
  <blockquote>
    <p>In addition, whenI set a language that doesn't exist:</p>
  </blockquote>
  
  <pre><code>www.sete.com/xx/xxx?l=NotFound 
  </code></pre>
  
  <p>I get an error in response like this:</p>
  
  <pre><code>{
      "user": "yaml%!(EXTRA string=Tom....)"
  }
  </code></pre>
  
  <h2>So , what should I do to better solve these problems? I tried my best, my English is not good, please help me.....</h2>