Skip to content

Add a command line interface.#3

Merged
SlexAxton merged 7 commits intomessageformat:masterfrom
Filirom1:master
May 17, 2012
Merged

Add a command line interface.#3
SlexAxton merged 7 commits intomessageformat:masterfrom
Filirom1:master

Conversation

@Filirom1
Copy link
Contributor

@Filirom1 Filirom1 commented Apr 3, 2012

Hi,

What do you think of the idea of a CLI tool for messageFormat.

I made one that iterates recursively in a folder and compile each json found.

$ cd example/
$ ../../bin/messageformat.js -l en
$ cd ../fr
$ ../../bin/messageformat.js -l fr

I commited the exemple : https://github.com/Filirom1/messageformat.js/tree/master/example

And the CLI sources, you can take a look at the options: https://github.com/Filirom1/messageformat.js/blob/master/bin/messageformat.js.

This is a one evening hack, forked from https://github.com/Filirom1/universal-jst, but if you like the idea, I could do something better.

Cheers
Romain

@SlexAxton
Copy link
Member

I'll play around with this. I want to also build some bindings to add the lib to the major templating languages that are precompilable. This helps for the most generic case, as well.

I'm at JSConf right now, but I'll dive deeper within a few days. I'm definitely interested in getting this right.

@Filirom1
Copy link
Contributor Author

Filirom1 commented Apr 4, 2012

How lucky you are !!! I would love to be at the JSConf right now.

I have a lot of ideas about new features in the CLI.

  • parse YAML in addition to JSON, and why not more format.
  • generate several compiled-i18n for each lang found
  • register a folder containing custom locales
  • have a default i18n used if nothing found in the current locale (like requireJs i18n)

I did this because I don't use RequireJs anymore and I miss the i18n plugin. Now I am quite happy because messageformat.js looks far better than the i18n plugin.

In my search for a RequireJs alternative, I am helping the universal-jst project that precompile the major templating languages in the JST format. So if we add some bindings to the templating engines, I will just be too happy to include it in universal-jst

Cheers
Romain

Copy link
Member

Choose a reason for hiding this comment

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

Should we create a bin and allow it to be installed globally? Seems potentially useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done :)

@SlexAxton
Copy link
Member

Cool. I did a code-read and everything seems legit. I definitely want to do template integrations, and I potentially want a different or multiple ways to store the data (like all langs in one file, or langs in separate files).

@Stuk and I are discussing whether we think it'd be a good idea to do some sort of 'contexts' like in gettext. I know it would be helpful in my projects. I don't think that should change a whole lot on this front though.

Awesome work. What's next? Do you want to work on it more (you mentioned wanting to add things), or should we pull it in now and go from there?

@Filirom1
Copy link
Contributor Author

Filirom1 commented Apr 7, 2012

There are some issues for Windows (you can take a look at the recent universal jst commits in my repo), I will fix it this week.

About watchr, it is the only lib I found that do recursive folder watching right but it force us to add coffee script in our deps :-/

Sure it's important that user could use the cli with a global install.

Take the code, it's ours, change it as you want, I will do pull requests if I add new features.

@Filirom1
Copy link
Contributor Author

Filirom1 commented Apr 9, 2012

Everything is ok for me now.

But for the future, I have several questions ...

How to handle multiple locales ?

  • like in rails, the root key is the locale ? so we could have several lang in one file
  • like in requireJs ? one lang per folder so we could recursively analyse the project and find the locale used.

How to handle not translated keys in one lang ? Use a fallback lang, print a warning, ...

And how to export the compiled messageformat when several lang are detected? one file, several files, ...

How to handle comments and multilines?

  • JSON is very bad for this.
  • JS files could be better,
  • Coffee-Script would rock but comments starts by #, but this sign is reserved by messageformat
  • Yaml as well use the # sign

@SlexAxton
Copy link
Member

Any chance we can get some docs on this? I'd feel pretty comfortable getting this in master as long as people were aware that it was in early development and had some usage docs.

@Filirom1
Copy link
Contributor Author

Just happy to do it :)

@kalebdf
Copy link

kalebdf commented May 10, 2012

@Filirom1 I like the way that this CLI tool is going! How do you plan on handling failover messages (defaults...)?

@Filirom1
Copy link
Contributor Author

Curently it is not handled. If you have an idea how to do it, please tell me. I am wondering about this (#3 (comment)). So all your suggestions are more than welcome.

@SlexAxton
Copy link
Member

Gonna go ahead an pull this in.

SlexAxton added a commit that referenced this pull request May 17, 2012
Add a command line interface.
@SlexAxton SlexAxton merged commit afa0cc2 into messageformat:master May 17, 2012
eemeli added a commit that referenced this pull request Dec 16, 2018
Make the parser conform to ICU MessageFormat
eemeli added a commit that referenced this pull request Jan 1, 2019
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