retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
9.86k stars 647 forks source link

[FR] For universal engine #123

Closed trsh closed 5 years ago

trsh commented 6 years ago

So I'm processing workers on back-end. I cloned the c++ code (https://github.com/retejs/cpp-engine) to Rust, and I have one big issue. It's that title (I guess name in current v.) is used to identify the workers. Strings that represent Visual labels of things should never be used identifiers. Because it can get long, it can get Chinese, etc. So possible solutions:

1) Boxed: let's add and ID for component, that has some limitations in characters. 2) Universal: let's add some custom param for Component, where we can put any JSON, and it will be added to editor.toJSON(), to any node. Than programmer can decide on it's self, how to organize the identifiers.

Ni55aN commented 6 years ago

Visual labels of things should never be used identifiers

Why not? You can use custom templates, where you can write any titles. And since the names are unique, each time writing the same line for the identifier would be inconvenient

Because it can get long, it can get Chinese, etc.

Why not x2 ? If there is a correct encoding, then all this will be safely stored in JSON format. After all, there is "data" property in addition to the "name" field, in which anything chars can be stored

trsh commented 6 years ago

@Ni55aN

1) I can write Title in my language "Lielais Lācis", because it needs to be in my language represented. And then other foreign programmers will have to wonder what's that . I can have also translations. Etc. I can go wrong is so much directions.

2) The second solution actually presents no dangers to existing solution. Just opportunities.

Ni55aN commented 6 years ago

@trsh

  1. You can write node's name in English (as accepted in the world community), and replace it in custom template on specific language (a kind of translator)
<div class="name">{{name | translate}}</div>
var translations = {
  ru:{
    'hello': 'привет'
  }
}

alight.filters.translate = function(exp, scope) {
    return function(value) {
        return translations.ru[value]
    }
}

http://jsfiddle.net/pTT5x/10/

trsh commented 6 years ago

So even I have a tiny nodes system, I have to add custom template to deal with the Name thing? Seems odd to me.

Adding custom data to json, on component level, still seams a good idea to me.

Ni55aN commented 5 years ago

Let's summarize:

By the way, there is a great translation tool called vuex-i18n