title: Global function in Ionic 3
body: <p>I would like to create a global function called "translate". As i know, i can define global variables and their values in the app.module.ts file. So i tried following code:</p>
  
  <pre><code>export function translate(string) {
    // i am not sure if it would make a difference if i would use var
    let ts = new TranslateService();
    return ts.get(string).subscribe(res=&gt;{
      return res;
    }); 
  }
  </code></pre>
  
  <p>So maybe i try to use the wrong class, maybe the mistake is somewhere else. I use the <a href="https://ionicframework.com/docs/developer-resources/ng2-translate/" rel="nofollow noreferrer">ngx-translate Module</a> (and it works great). Instead of always declaring to use the "TranslateService" (in every class where a translation is needed), i want to have a global function, where i can access the translations via only a function (i do not want to call another class...). You can see the code that i do like to use in the global function at the very end of the link (<a href="https://ionicframework.com/docs/developer-resources/ng2-translate/" rel="nofollow noreferrer">ngx-translate</a>)</p>
  
  <p>Thanks in advance.</p>
  
  <p>global means for me, that something is accessible everywhere in the project.</p>