Need to create resource bundle


#1

Hello All,

I need to create resource bundle type of file in ember. Can anybody please help me in guiding how to do it?

Thanks & Regards, Priyanka


#2

Hi @parekhpiya2002, wha do you mean by “resource bundle type”?


#3

Thanks for your response. I need to create a single file in which i will list all configurable parameters required in project and will call anywhere its required.

It will be useful for data re usability.

Do you have any idea about the same?


#4

Are you familiar with JavaScript modules? You can export an object, and then import that module from anywhere, similar to the config module. See documentation for the utils folder.


#5

Actually,I am new to JS and ember too. Can you please provide me any reference link?

Thanks & Regards, Priyanka


#6

@parekhpiya2002 Just trying to clarify something. As I understand, you want to create environment specific variables?

For example, if you want to specify a different api URL on development and production, you can do the following:

  1. Open app/config/environment.js
  2. Define your value, like so: ENV.apiURL = "http://localhost:3000" inside the environment === 'development' check.
  3. Repeat the above step for every environment

Then, to access your configuration, in any other route/component, you can do at the top: import config from "../../path/to/config/environment"

and then access the variable using config.apiURL.


#7

Thanks for reply.

I will try this first


#8

cool, let me know how it goes!


#9

i have added one configurable parameter in environment.js as ‘ENV.Create_Table = “Create Table”;’

How i can print this value on .hbs file?

Thanks & Regards, Priyanka


#10

You might want to use ember-i18n (https://github.com/jamesarosen/ember-i18n) for localization needs, and define translation files as json.


#11

Thanks for your reply but i dont want to set language file. I want to store some environment variables in single file so that it can be easily reusable and easy for updation.

Thanks & Regards, Priyanka


#12

Like @locks mentioned, now that you have your createTable variable in your environment config you can simply import it in your controller for use in your template.

So your controller would look something like:

// application controller
import Ember from 'ember';
import config from '/path/to/environment/config';

export default Ember.Controller.extend({
    createTable: config.createTable   //this makes the value available for use in the template
}); 

And then your in your template

{{!-- application.hbs --}}
{{createTable}}