I am not battling with @OvermindDL1, I respect his opinion a lot
I just tell how it is done in Ruby, and coming from a multi-languages country (4) I had to solve this kind of problem.
I am not battling with @OvermindDL1, I respect his opinion a lot
I just tell how it is done in Ruby, and coming from a multi-languages country (4) I had to solve this kind of problem.
Letâs say You add a published boolean field, This would have to be set in all records, or did I miss something?
I am sorry I think my way of expressing it was not proper what I meant is that 2 opinions you both offered have some advantages and differences.
@OvermindDL1 use the idea of languges code in each table, that speeds up the database look up.
@kokolegorille, your idea is to bring one table will act as an observer to decide which languge is needed to be displayed and your solution doesnât repeat the langauges codes in all the tables.
I also respect both of your opinions and your experiences.
I hope that I didinât offend any of you.
Oh absolutely not! You want to publish each individually. You could easily have, say, an english one published and still be working on a german one to be published later when you finish it. ^.^;
Ok, the published example is too simplist.
Letâs say You have a lot of metadata (position, counter cache etc.), unrelated to translation content
Then normalize the data as per standard SQL, move that identical part out. ^.^
Shouldnât position/counterâs etc⊠be language specific too though? Itâs trivial to aggregate them in sql but itâs impossible to peal them apart if needed (like to see language specific stats).
Oh, position is to set a specific order, not to be calculated.
Itâs again a Ruby example, from acts_as_list gem.
I also use lft and rgt fields quite often for nested set⊠and this data should not be duplicated. I use this hierarchy when dealing with Page and SubPage (and SubSubPage).
Huh? Whatâs that?
Never heard of so please assume no prior knowledge. ^.^;
Huh? o.O
What would You do if You want to set an arbitrary order?
I used Ruby/Rails before, that is why I often compare both.
Joe Celkoâs SQL for smarties, how to represent a tree in a database.
Iâve always used the published-date for that. My usual published
field (like at work) isnât a boolean, itâs a nullable datetime field. If null then itâs invisible and that wonât change. Once published then it sets to ânowâ so itâs visible and ordered with other datetimes in relation to that. Or I can set it in the future and it will be visible at that point. As translations are finished you can set them to all the same date if you want, but it might be useful to set a translation at a later date (like at the time it was finished) if you so wish so it gets ordered at the top of a language-specific ânewâ page.
I mostly come from web frameworks in C++, erlang, and I hate to admit it but PHP (it was paid work so ehâŠ), never touched ruby to date. ^.^;
Heh, never heard of such a thing. Do you have a link of descriptions? Iâm curious if there are ideas I can swipe. ^.^
I had a request for a productâs catalog, where user should be able to choose in which order products would be displayed.
http://www.ibase.ru/files/articles/programming/dbmstrees/sqltrees.html
also
So you use order_by? or what method did you use to accomplish this?
Sure add an order field then. Doesnât mean other translations wonât want a different order (youâd be surprised, like big timeâŠ). ^.^
From just a quick initial look (itâs now in my to-read list) isnât this significantly more easily solved via the path datatype in pgsql? He even says at the end you should stick to a sql server that at least has arrayâs in it, lol.
I use order_by position.
But it is done in a way the end user does not have to set position, it is done at the server level.
I use sortable js and the end user can freely drag and drop items to reorder them.
Oh drag and drop and update the position of the item when the user drop the item?
Can you share your method please?, I saw something similar in node.
I made some libs with webpack to build lists and trees⊠It uses fetch to send data to server, where the order is persisted.
const buildList = id => {
// If no id is defined, select the first element with class sortable
let list = id ?
document.getElementById(id) :
document.getElementsByClassName('sortable')[0];
// https://github.com/SortableJS/Sortable
if (list) {
const {url} = list.dataset;
Sortable.create(list, {
onUpdate: (/**Event*/evt) => {
const data = {oldIndex: evt.oldIndex, newIndex: evt.newIndex};
// Post data as query string and use right headers
fetch(url, {
method: "POST",
headers: {
"Content-type": "application/x-www-form-urlencoded"
},
body: toQueryString(data),
})
.then(resp => {
// Handle data
console.log(resp);
}).catch(error => {
// Handle error
console.log(error);
});
},
});
} else {
console.log("No List found.");
}
}
Thanks here is an example with vue I think it does the same thing https://codepen.io/phphe/pen/KRapQm
When it comes to SQL, I like his books a lot, but itâs not recent.
Yes, similar, but I use vanilla JS instead.
I like Vue more because it is structured and clear, anyone that looks over the code will understand what is happening and also the vue-cli and vue-ui makes development a pleasure. You should try it sometime.