-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: t macro and docs #7821
feat: t macro and docs #7821
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
At some related discussion members @pmario @Gk0Wk @sycom @joshuafontany @tobibeer |
Pretty interesting. Some questions
Not exactly the same purpose, but I've been working on translation lately. Just have not enough time to publish and comment, sorry for that. I'll do a push asap on my repo. Will tell you. My approach is a bit different: it's a plugin that enables translation capabilities. Translations are fully independent. You can translate any tiddler without modifying original one. |
What does this mean? This macro is just a simple string replacement like https://www.i18next.com/ which is widely used in modern frontend dev in my daily work. |
Do I need to install all possible translations, if I do install the plugin? -- If yes that's an absolute "no go" for me. |
Ok I get it. You have to install the language plugin to switch from one language to another.
Sorry for being unclear. My English is a bit odd... I understand that only predefined tiddler or part of tiddlers can be translated. So will you be able to translate someone else's plugin that didn't anticipate the translation ? |
No, as you can see, texts are in normal tiddlers, you can pack them to a separate plugin. Just make them sub-plugin. |
language plugin is for tw cores translation. here we just read the language config. you don't need to install additional plugin to use translation of your plugin, if you put all translations in your plugin. |
Thanks for your answers. So if I get all this correctly, the macro offers possibilities without killing existing ones which is good. I don't see problematic behaviour. I'm not "core fluent" enough to evaluate if it's worth adding it to the core though. If your macro is not integrated to the core, you may publish it elsewhere. It will surely be interesting for other users. For your information, as mentioned above, I pushed my first release of t8n plugin if you want to check this alternative approach. Code on codeberg : https://codeberg.org/sycom/TiddlyWiki-Plugins |
Thanks @linonetwo, and sorry to have missed this when you first posted it. I like the general idea here, but have a couple of thoughts:
|
It takes me 10 min to learn and refactor to \procedure, and 1 hour to learn & refactor to \function . It was a good introduction exercise for me... I also update the doc, see it in "Docs in Preview site" at #7821 (comment) @Jermolene Please check this again. |
@Jermolene Hi, please take time for this, every time I develop a plugin, it reminds me of this. |
Hi @linonetwo thank you for the updates. Thinking again, we do not need to introduce a new procedure here. I think we can overload the existing
A couple of changes from your version:
One benefit of this approach is that it allows us to use I also think that it would be good if we could include add translations for one of the core plugins to act as an exemplar of best practice. I would suggest the "tiddlywebadaptor" plugin, but would be open to suggestions. Perhaps you could include the Chinese translations, and then others can contribute other languages. |
Very interesting approach, I've updated the definition and the doc. These features are even advanced for me, it is the first time for me to use them. @Jermolene new doc is in https://tiddlywiki5-25onfr134-jermolene.vercel.app/#lingo%20Macro , let's see if it is clear. |
Hi @linonetwo I think this is ready to merge. Would you please be able to resolve the merge conflicts? |
Cool, will do it now, I was playing game during duanwu festival last few days. |
I added
to demonstrate the tree structure of i18n file: But consider the potential change will made in #8234, I decided not to include it in this PR. I want to add it back, because in the doc I add a link to help user understand the structure: Now hope this is ready for merge. |
This reverts commit fb70f0b.
Thanks @linonetwo |
Hi @linonetwo I think the problems revealed in #8262 and #8263 will require significant rework to get things working. It is entirely my fault for suggesting this approach in the first place. I did not consider how the language plugin switching mechanism interacts with language dependents mechanism. Although ingenious, the fix in #8269 is not sufficient because it does not work where there are more than one dependent language plugin, or if the dependencies are nested more than two levels. I suspect that an effective fix will likely require JS changes to the language plugin switching code. I am very sorry for the disappointment but I propose to revert this PR for v5.3.4 so that we can work on a robust implementation for a subsequent release. |
So maybe use JS to rewrite lingo macro? Writing JS version will be very easy for me, We can keep the same marco params, but use JS to cache translation from plugin to speed up rendering, also handle fallback cases.
I think this case is very rare, why not handle this in next release, but provide this feature in this release, as long as the API won't change. So plugin authors can start writing i18n. I can also write a JS macro version, to see if we can let this feature catch this release. But it's indeed good to delay this to next release, so it's not so hurry. I only PR for fun, this feature exists as patch in TidGi, so this doesn't affect my daily usage. |
Hi @linonetwo I understand the arguments but my concern is that the eventual fix for this may not be backwards compatible with this partial fix. You will be familiar with the way that much of the logic for handling language plugins is in this JS function: One reasonable approach to consider would be for the language plugin switching code to somehow also harvest translation strings from other plugins if they are present. With such a solution, the language strings would need to be marked in some way, and perhaps require other fields. None of that would be compatible with the partial fix here, but it would be quite efficient and congruent with the existing architecture. So, I think this needs more thought and experimentation before we can propose a solution. |
@Jermolene I will write a JS macro that consider the usage in pluginswitcher.js soon, just need you to decide:
|
Hi @linonetwo I am not sure that that is necessarily the best way to go. I wonder if there is an alternative approach where we leave the existing macro untouched, and do the work of folding in add-on translations upfront, in the switchPlugins method. It would work like the "$:/info/*" mechanism, which generates a temporary plugin |
@Jermolene I'm learning Lean4 language these days, but I might write a demo at weekend. Where will the translation go? In previous design, they will be placed at And these tiddlers are being clone to |
My initial concept was completely different. I think your code from https://github.com/linonetwo/TiddlyWiki5/blob/e9568720489ae5fe9ee74cd16330b8168028beff/core/wiki/macros/lingo.tid could be changed in a way, that it can resolve several dependents with several levels deep. But imo it would need a recursive wikitext procedure, with an "endless loop" protections, which makes it much more complex and hard to maintain. TLDR; I think the mechanism can be even simpler than the one Jeremy suggests at: #7821 (comment) I think it will be possible to keep the directory structure and the plugin naming conventions in place. But instead of "extracting" every plugin tiddler at startup and have a complex lingo-macro it should be simpler. At wiki startup and if language is switched
The good thing will be, that the ControlPanel -> Plugins -> MenuBar -> Contents tab will only show The
The |
Original i18n tiddlers should be placed under I think the approach is clear now, this also sometimes allow directly transclude the tiddler, instead of need to use I will take time for this, but I'm going to build an AI character chat plugin this weekend because I just gain lots of interest on it. |
This change was accidentally missed when reverting #7821
…8246" This change was accidentally missed when reverting TiddlyWiki#7821
See #8435
Docs in Preview site
The old
lingo
macro can only work with language plugin, which is very restricted, we plugin developers don't have a chance to use it easily.The new
t
macro make it flexible for plugin developers (or even normal users that want their blog to be international) to do translation.The implementation is simple, works in user-land, and is compatible with infra like i18n ally. (Possibly can use with i18n ally with inline annotation, if lokalise/i18n-ally#1021 is solved.)
fixes #4179 fixes #786 closes #5418