Look at:
lib/modules/apostrophe-areas/lib/cursor.js
Notice that in lib/modules/apostrophe-areas/lib/api.js this gets pulled in with:
// merge new methods with all apostrophe-cursors
self.apos.define(āapostrophe-cursorā, require(ā./cursor.jsā));
You could do that too. Your new definition of the filter would āwin.ā Itās implicit subclassing, just like with modules, itās just a type thatās not a module.
However you have the problem that youāll want to extend the old definition rather than copying and pasting so much code. And you would be better off anyway intercepting before the areas module adds the area
filter.
So I would suggest something like improving apostrophe-docs
(which I believe youāre already doing), which also defines apostrophe-cursor
(for the first time), and adding an additional definition of apostrophe-cursor
there; a new filter (localize would be a good name) that you add there should run its after
handler before one added by apostrophe-areas
, because the docs module is initialized before all other modules that care about docs, and your improvement of it counts as part of it. It could also swap in the right version of the title
property, and so on. This gets us back to the ability to solve this like in 0.5.
But there are still some interesting problems, like how UI filters for various fields are supposed to work across languages. That would make our mongo queries a lot more complex.
It makes me wonder if there should be a separate object in the docs collection for each localization; that would make the localize filter very simple āit would just call .and({ culture: culture })
. And your overrides for saving documents might get simpler too. They would just introduce the appropriate culture property.
In this scenario, slugs would have to be distinct for each language (because of the unique index), but that could be desirable.
Falling back to the default language would be a little tricky in this implementation. Or very easy, if you decide that they all get created as needed on save, so they are always in the database even if they are initially just copies of the default languageās content.
What else is tricky in this scenarioā¦ joins. They would probably need to continue to point to the default cultureās version of the doc being joined with.
Possibly this could be addressed by changing IDs to look like:
xxxxx-CULTURE
So the right suffix could just be added. But certainly our join loader would need some new logic.
This is a big issue. (: