Skip to content

Commit

Permalink
Add languages: French, Japanese
Browse files Browse the repository at this point in the history
  • Loading branch information
Giovanni Lovato committed Jul 27, 2017
1 parent f66a06b commit db4be18
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 4 deletions.
25 changes: 25 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,34 @@ image:https://img.shields.io/github/license/heruan/humanize.svg[link=http://www.

image:https://img.shields.io/maven-central/v/to.lova.humanize/humanize-time.svg[title=humanize-time]

Add the dependency to your `pom.xml`:

[source,xml]
----
<dependency>
<groupdId>to.lova.humanize</groupId>
<artifactId>humanize-time</artifactId>
<version>0.1.1</version>
</dependency>
----

Use it in your code as simple as:

[source,java]
----
Temporal minutesAgo = ZonedDateTime.now().minus(5, ChronoUnit.MINUTES);
String relative = HumanizeTime.fromNow(minutesAgo);
// produces: "5 minutes ago"
----

By default it uses the locale provided by `Locale.getDefault()`, but you can request a different one or provide your own resolver:

[source,java]
----
Temporal minutesAgo = ZonedDateTime.now().minus(5, ChronoUnit.MINUTES);
Locale.setDefault(Locale.ITALIAN);
String italian = HumanizeTime.fromNow(temporal);
// produces: "5 minuti fa"
String english = HumanizeTime.fromNow(temporal, Locale.FRENCH);
// produces: "5 minutes"
----
4 changes: 2 additions & 2 deletions humanize-time/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<parent>
<groupId>to.lova.humanize</groupId>
<version>0.1.1</version>
<version>0.1.2</version>
<artifactId>humanize-parent</artifactId>
</parent>

Expand All @@ -23,4 +23,4 @@
</dependency>
</dependencies>

</project>
</project>
29 changes: 29 additions & 0 deletions humanize-time/src/main/resources/messages_fr.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
now=à présent
seconds.ago[one]=il y a un instant
seconds.ago[other]=il y a {0,number} secondes
minutes.ago[one]=il y'a une minute
minutes.ago[other]=il y a {0,number} minutes
hours.ago[one]=il y a une heure
hours.ago[other]=il y a {0,number} heures
days.ago[one]=il y a un jour
days.ago[other]=il y a {0,number} jours
weeks.ago[one]=il y a une semaine
weeks.ago[other]=il y a {0,number} semaines
months.ago[one]=il y a un mois
months.ago[other]=il y a {0,number} mois
years.ago[one]=il y a un an
years.ago[other]=il y a {0,number} ans
seconds.within[one]=dans une seconde
seconds.within[other]=dans les {0,number} secondes
minutes.within[one]=dans une minute
minutes.within[other]=dans les {0,number} minutes
hours.within[one]=dans une heure
hours.within[other]=dans les {0,number} heures
days.within[one]=en un jour
days.within[other]=dans le {0,number} jours
weeks.within[one]=dans une semaine
weeks.within[other]=dans les {0,number} semaines
months.within[one]=dans un mois
months.within[other]=dans les {0,number} mois
years.within[one]=dans l'année
years.within[other]=dans le {0,number} ans
29 changes: 29 additions & 0 deletions humanize-time/src/main/resources/messages_ja.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
now=今
seconds.ago[one]=一秒前
seconds.ago[other]={0,number}秒前
minutes.ago[one]=一時間前
minutes.ago[other]={0,number}時間前
hours.ago[one]=一時間前
hours.ago[other]={0,number}時間前
days.ago[one]=一日前
days.ago[other]={0,number}日前
weeks.ago[one]=一週間前
weeks.ago[other]={0,number}週間前
months.ago[one]=一ヶ月前
months.ago[other]={0,number}ヶ月前
years.ago[other]=一年前
years.ago[other]={0,number}年前
seconds.within[one]=一秒以内
seconds.within[other]={0,number}秒以内
minutes.within[one]=一時間以内
minutes.within[other]={0,number}時間以内
hours.within[one]=一時間以内
hours.within[other]={0,number}時間以内
days.within[one]=一日以内
days.within[other]={0,number}日以内
weeks.within[one]=一週間以内
weeks.within[other]={0,number}週間以内
months.within[one]=一ヶ月以内
months.within[other]={0,number}ヶ月以内
years.within[other]=一年以内
years.within[other]={0,number}年以内
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

public class TimeUnitTest {

private static final Temporal NOW = ZonedDateTime.now();
private static final String REFERENCE_TIME = "2007-12-03T10:15:30+01:00[Europe/Paris]";

private static final Temporal NOW = ZonedDateTime.parse(REFERENCE_TIME);

@Test
public void testStaticMethods() {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>to.lova.humanize</groupId>
<artifactId>humanize-parent</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>

<packaging>pom</packaging>

Expand Down

0 comments on commit db4be18

Please sign in to comment.