Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply to file instead of folder #21

Open
alvarotrigo opened this issue Feb 13, 2018 · 9 comments
Open

Apply to file instead of folder #21

alvarotrigo opened this issue Feb 13, 2018 · 9 comments

Comments

@alvarotrigo
Copy link
Contributor

alvarotrigo commented Feb 13, 2018

It would be great if we could apply the static-i18n command to a single file instead of to a folder.

I personally have my index.html file in the root path, and I would prefer to keep it that way because that's gonna be the structure in my hosting.

Right now I'm forced to place it within a folder so static-i18n can work over it, therefore messing my relative paths when outputing the result in a 2 levels depth path.

From ./www/index.html to i18n/es/index.html.

The other option would be to be able to configure the output path, so instead of having i18n/es/index.html we could have es/index.html and therefore solving the relative paths issue.

@danhper
Copy link
Member

danhper commented Feb 14, 2018

Thanks for reporting. I will look into it soon.
By the way, if it can help you contributing I'm perfectly fine switching to plain JS instead of CoffeeScript.

@alvarotrigo
Copy link
Contributor Author

By the way, if it can help you contributing I'm perfectly fine switching to plain JS instead of CoffeeScript.

How did you know I work with plain JS? :D
Yeah, I never used coffescript before

@danhper
Copy link
Member

danhper commented Feb 14, 2018

How did you know I work with plain JS? :D

Your profile spoke for itself 😄
CoffeeScript kind of made sense when I started the project years ago,
but not really anymore. Hopefully it should not be too hard to transform
this to JS. Unless this and the other issues you raised are urgent,
let's start by transforming this to JS before fixing the rest.

@alvarotrigo
Copy link
Contributor Author

Hopefully it should not be too hard to transform
this to JS.

The node module is already generated in .js. So we can just take that as the base?

@danhper
Copy link
Member

danhper commented Feb 14, 2018

The node module is already generated in .js. So we can just take that as the base?

Yes, the code is not really pretty so it will need a bit of work, but it is more or less usable.

@danhper
Copy link
Member

danhper commented Feb 15, 2018

I finished changing everything to JS and published a beta version to npm. It worked with my projects, but it would be great if you could give it a try, thanks.

Concerning this issue, you can already run static-i18n on a single file by using the --files options, for example

static-i18n -l en -i en -i fr --files 'index.html' .

If you want to configure the output path, you can use --output-dir as follow:

static-i18n -l en -i en -i fr www --output-dir .

Let me know if any of these option would work for your use case.

@alvarotrigo
Copy link
Contributor Author

alvarotrigo commented Feb 27, 2018

This is not working for me:

static-i18n -l en -i en -i es -i ru -i ko -i zh --fileFormat yml --allowHtml true --files 'demo.html'

I'm getting:

usage: static-i18n [options] directory

@alvarotrigo
Copy link
Contributor Author

alvarotrigo commented Feb 27, 2018

Ok, I had to add the . at the end

static-i18n -l en -i en -i es -i ru -i ko -i zh --fileFormat yml --allowHtml true --files 'demo.html' .

I'm using a file within a folder, so 'www/demo.html' . ends up creating i18n/es/www/demo.html instead of i18n/es/demo.html.

I tried using the --output-dir . param, but I get

usage: static-i18n [options] directory

With

static-i18n -l en -i en -i es -i ru -i ko -i zh --fileFormat yml --allowHtml true --files 'www/demo.html' --output-dir .

@danhper
Copy link
Member

danhper commented Mar 1, 2018

If your files are in the current directory, your first command is correct, but if they are in the www directory, it should be

static-i18n -l en -i en -i es -i ru -i ko -i zh --fileFormat yml --allowHtml true --files 'demo.html' www

For your second command, you are missing the input directory, as the final . is interpreted as the output directory. If you want to use the files in www as input, just append www to your last command.

static-i18n -l en -i en -i es -i ru -i ko -i zh --fileFormat yml --allowHtml true --files 'demo.html' --output-dir . www

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

No branches or pull requests

2 participants