runkids / vue2-timeago Goto Github PK
View Code? Open in Web Editor NEW:raised_hands: A vue component used to format date with time ago statement. :speech_balloon:
Home Page: https://vue2-timeago.netlify.app/
License: MIT License
:raised_hands: A vue component used to format date with time ago statement. :speech_balloon:
Home Page: https://vue2-timeago.netlify.app/
License: MIT License
file, ro.js
function formatToLongString (time, type) {
if(type == 'zi')
return ` ${time == 1 ? 'o ' : time} ${ time == 1 ? '' : 'e'} în urmă`
return ` ${time == 1 ? 'o ' : time} ${type}${ time == 1 ? 'ă' : 'e'} în urmă`
}
export default {
short: {
now: 'chiar acum',
sec:'s',
min: 'm',
hour: 'o',
day: 'z',
},
long: {
now: 'chiar acum',
sec: time => formatToLongString(time, 'secund'),
min: time => formatToLongString(time, 'minut'),
hour: time => formatToLongString(time, 'or'),
day: time => formatToLongString(time, 'zi'),
}
}
WARNING in ./node_modules/vue2-timeago/dist/vue2-timeago.js 1:294-298
Critical dependency: the request of a dependency is an expression
Any idea how to fix that?
function formatToLongString (time, words) {
let _time = time % 100;
if (_time > 19) {
_time = _time % 10;
}
switch ( _time ) {
case 1: {
return ` ${time} ${words[0]} назад`;
}
case 2: case 3: case 4: {
return ` ${time} ${words[1]} назад`;
}
default: {
return ` ${time} ${words[2]} назад`;
}
}
}
export default {
short: {
now: 'только что',
sec:'с',
min: 'м',
hour: 'ч',
day: 'дн',
},
long: {
now: 'только что',
sec: time => formatToLongString(time, ['секунда', 'секунды', 'секунд']),
min: time => formatToLongString(time, ['минута', 'минуты', 'минут']),
hour: time => formatToLongString(time, ['час', 'часа', 'часов']),
day: time => formatToLongString(time, ['день', 'дня', 'дней']),
}
}
instead of publishing a public file to this repository it would be nice if the parameter locale
could accept an object as input [containing all the translation definitions], allowing everyone to write and load custom translations
export default {
short: {
now: "قبل قليل",
sec: " ثانية",
min: " دقيقة",
hour: " ساعة",
day: " يوم"
},
long: {
now: "قبل قليل",
sec: " ثواني مضت",
min: " دقائق مضت",
hour: " ساعات مضت",
day: " أيام مضت"
}
}
Please note that we don't have the same as English. This means that instead of 5 minutes ago, we write before 5 minutes
There fore, if you can replace the $value with the time-left, it would be better. Otherwise, you can use the first list, which doesn't require you to reorder the logic of your code. The first list above uses the same as English. I prefer the second one.
Also, there's a difference between singular and plural. If you could implement this, please let me know so i can give you a better translation.
export default {
short: {
now: "قبل قليل",
sec: " ثانية",
min: " دقيقة",
hour: " ساعة",
day: " يوم"
},
long: {
now: "قبل قليل",
sec: " قبل $time ثواني",
min: " قبل $time دقائق",
hour: " قبل $time ساعات",
day: " قبل $time أيام"
}
}
不知道怎么回事,在翻页的时候,时间显示的是第一页的数据,比如12条数据,第一页都是正常的,但第二页开始,前2条的时间数据是第一页的前两条。
我换了 vue-timeago 是没有问题的,请测试下。
function formatToLongString(time, type) {
return `${time} ${type}${time > 1 ? 's' : ''} fa`
}
export default {
short: {
now: 'adesso',
sec: 's',
min: 'm',
hour: 'o',
day: 'g',
},
long: {
now: 'adesso',
sec: (time) => formatToLongString(time, 'secondi'),
min: (time) => formatToLongString(time, 'minuti'),
hour: (time) => formatToLongString(time, 'ore'),
day: (time) => formatToLongString(time, 'giorni'),
},
}
Using the tag <time-ago>
in HTML doesn't work, but <vue2-timeago>
works.
Is README.md outdated? Or is it a bug?
There is about 10x more popular package: vue-timeago
created by egoist
.
https://www.npmjs.com/package/vue-timeago
but now this repository is archived
https://github.com/egoist/vue-timeago
vue-timeago
, or totally other concept under the hood?Below I paste the Polish translation. Thanks!
locale="pl"
function formatToLongString (time, type) {
return ` ${time} ${type}${ time > 1 ? 's' : ''} temu`
}
export default {
short: {
now: 'przed chwilą',
sec:'s',
min: 'm',
hour: 'g',
day: 'd',
},
long: {
now: 'przed chwilą',
sec: time => formatToLongString(time, 'sekund'),
min: time => formatToLongString(time, 'minut'),
hour: time => formatToLongString(time, 'godzin'),
day: time => formatToLongString(time, 'dni'),
}
}
Hebrew support for time-ago
Is it possible to get rid of the timestamp and just leave the "xxx min/days ago"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.