assemble / grunt-assemble-i18n

Assemble middleware for adding i18n support to projects.
24 stars 8 forks source link

Need a way to flatten the output of "with-plugin" #22

Closed LaurentGoderre closed 10 years ago

LaurentGoderre commented 10 years ago

Right now, it preserves the structure of the templates which is not necessarily the desired behavior.

Any idea how we would tackle that?

ain commented 10 years ago

I used assemble-contrib-permalinks for it, works nicely on 2 projects already.

jonschlinkert commented 10 years ago

have you tried the files array format? if that doesn't work, the permalinks plugin would be my suggestion as well. I don't think this complexity belongs in the i18n plugin

LaurentGoderre commented 10 years ago

Files array shouldn't work because it's a custom array

doowb commented 10 years ago

It is flattened, isn't it?

LaurentGoderre commented 10 years ago

No, it preserves the path of the template

jonschlinkert commented 10 years ago

Good point, I forgot about that

Sent from my iPhone

On Mar 4, 2014, at 9:48 AM, Laurent Goderre notifications@github.com wrote:

Files array shouldn't work because it's a custom array

— Reply to this email directly or view it on GitHub.

LaurentGoderre commented 10 years ago

BTW, permalinks does not solve this issue. It adds the path to the template before the permalink

jonschlinkert commented 10 years ago

permalinks does not solve this issue. It adds the path to the template before the permalink

It does though, because the dest can be anything you want it to be:

assemble: {
  foo: {
    options: {
      permalinks: {
        structure: 'dist/:foo/:bar/:index:ext'
      }
    },
    files: {
      './': ['templates/*.hbs']
    }
  }
}

meaning that if the dest is "nothing", then permalinks constructs the entire dest path.

LaurentGoderre commented 10 years ago

This is what I have:

assemble:{
  theme: {
    options: {
      plugins: ['assemble-contrib-i18n'],
      i18n: {
        languages: ["en", "fr"],
        templates: ['site/pages/theme/*.hbs']
      }
    },
    dest:  "dist/unmin/theme/",
    src: "!*.*"
  }
}

The output of this is dist/unmin/theme/site/pages/theme/index-en.html

jonschlinkert commented 10 years ago

It should be something like:

assemble:{
  theme: {
    options: {
      plugins: ['assemble-contrib-i18n', 'assemble-contrib-permalinks'],
      i18n: {
        languages: ["en", "fr"],
        templates: ['site/pages/theme/*.hbs']
      },
      permalinks: {
        structure: 'dist/unmin/theme/:whatever/:props/:index:ext'
      }
    },
    files: {'./': ['!*.*']}
  }
}

The structure will build the dest how ever you want it.

jonschlinkert commented 10 years ago

the reason the permalinks plugin is advantageous for this kind of situation, is if you had multiple plugins that each attempted to modify the dest somehow you would run into problems quickly. but the permalinks plugin allows you to construct virtually any kind of dest path you can think of, and it will work with other plugins.

doowb commented 10 years ago

This is what I'm confused about... this example in the Gruntfile.js is the same thing... also flatten: true is in the assemble.options so that might be the reason that it's working in this example. You can see the results in the test/actual/with-plugin/ folder

LaurentGoderre commented 10 years ago

You're right...though @jonschlinkert example worked....I'm curious now...

LaurentGoderre commented 10 years ago

Damn I'm dumb....I forgot the flatten parameter. Sorry about that guys :S

jonschlinkert commented 10 years ago

lol no worries. this flexibility is a double-edged sword. I think our new docs will really help! we're working night and day to get them done!