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
Udpate French locale to match the new V2 API #778
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,41 @@ | ||
import buildFormatLongFn from '../../../_lib/buildFormatLongFn/index.js' | ||
|
||
var formatLong = buildFormatLongFn({ | ||
LT: 'HH:mm', | ||
LTS: 'HH:mm:ss', | ||
L: 'DD/MM/YYYY', | ||
LL: 'Do MMMM YYYY', | ||
LLL: 'Do MMMM YYYY HH:mm', | ||
LLLL: 'dddd, Do MMMM YYYY HH:mm' | ||
}) | ||
var dateFormats = { | ||
full: 'EEEE d MMMM y', | ||
long: 'd MMMM y', | ||
medium: 'd MMM y', | ||
short: 'dd/MM/y' | ||
} | ||
|
||
var timeFormats = { | ||
full: 'HH:mm:ss zzzz', | ||
long: 'HH:mm:ss z', | ||
medium: 'HH:mm:ss', | ||
short: 'HH:mm' | ||
} | ||
|
||
var dateTimeFormats = { | ||
full: "{{date}} 'à' {{time}}", | ||
long: "{{date}} 'à' {{time}}", | ||
medium: '{{date}}, {{time}}', | ||
short: '{{date}}, {{time}}' | ||
} | ||
|
||
var formatLong = { | ||
date: buildFormatLongFn({ | ||
formats: dateFormats, | ||
defaultWidth: 'full' | ||
}), | ||
|
||
time: buildFormatLongFn({ | ||
formats: timeFormats, | ||
defaultWidth: 'full' | ||
}), | ||
|
||
dateTime: buildFormatLongFn({ | ||
formats: dateTimeFormats, | ||
defaultWidth: 'full' | ||
}) | ||
} | ||
|
||
export default formatLong |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
var formatRelativeLocale = { | ||
lastWeek: '[hier] dddd [à] LT', | ||
yesterday: '[hier à] LT', | ||
today: '[aujourd’hui à] LT', | ||
tomorrow: '[demain à] LT', | ||
nextWeek: 'dddd [à] LT', | ||
lastWeek: "dddd 'dernier à' LT", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
yesterday: "'hier à' LT", | ||
today: "'aujourd’hui à' LT", | ||
tomorrow: "'demain à' LT'", | ||
nextWeek: "dddd 'prochain à' LT", | ||
other: 'L' | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,117 @@ | ||
import buildLocalizeFn from '../../../_lib/buildLocalizeFn/index.js' | ||
import buildLocalizeArrayFn from '../../../_lib/buildLocalizeArrayFn/index.js' | ||
|
||
var weekdayValues = { | ||
narrow: ['di', 'lu', 'ma', 'me', 'je', 've', 'sa'], | ||
short: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'], | ||
long: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'] | ||
var eraValues = { | ||
narrow: ['av. J.-C', 'ap. J.-C'], | ||
abbreviated: ['av. J.-C', 'ap. J.-C'], | ||
wide: ['avant Jésus-Christ', 'après Jésus-Christ'] | ||
} | ||
|
||
var monthValues = { | ||
short: ['janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin', 'juill.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'], | ||
long: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'] | ||
} | ||
|
||
var timeOfDayValues = { | ||
uppercase: ['AM', 'PM'], | ||
lowercase: ['am', 'pm'], | ||
long: ['du matin', 'de l’après-midi', 'du soir'] | ||
var quarterValues = { | ||
narrow: ['T1', 'T2', 'T3', 'T4'], | ||
abbreviated: ['1er trim.', '2ème trim.', '3ème trim.', '4ème trim.'], | ||
wide: ['1er trimestre', '2ème trimestre', '3ème trimestre', '4ème trimestre'] | ||
} | ||
|
||
function timeOfDay (dirtyHours, dirtyOptions) { | ||
var hours = Number(dirtyHours) | ||
var options = dirtyOptions || {} | ||
var type = options.type ? String(options.type) : 'long' | ||
|
||
if (type === 'uppercase') { | ||
return (hours / 12) >= 1 ? timeOfDayValues.uppercase[1] : timeOfDayValues.uppercase[0] | ||
} else if (type === 'lowercase') { | ||
return (hours / 12) >= 1 ? timeOfDayValues.lowercase[1] : timeOfDayValues.lowercase[0] | ||
} | ||
|
||
if (hours <= 12) { | ||
return timeOfDayValues.long[0] | ||
} else if (hours <= 16) { | ||
return timeOfDayValues.long[1] | ||
} else { | ||
return timeOfDayValues.long[2] | ||
} | ||
var monthValues = { | ||
narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'], | ||
abbreviated: ['janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin', 'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'], | ||
wide: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'] | ||
} | ||
|
||
function masculineOrdinalNumber (number) { | ||
if (number === 1) { | ||
return '1er' | ||
} | ||
|
||
return number + 'e' | ||
var dayValues = { | ||
narrow: ['D', 'L', 'M', 'M', 'J', 'V', 'S'], | ||
short: ['di', 'lu', 'ma', 'me', 'je', 've', 'sa'], | ||
abbreviated: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'], | ||
wide: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'] | ||
} | ||
|
||
function feminineOrdinalNumber (number) { | ||
if (number === 1) { | ||
return '1re' | ||
var dayPeriodValues = { | ||
narrow: { | ||
am: 'AM', | ||
pm: 'PM', | ||
midnight: 'minuit', | ||
noon: 'midi', | ||
morning: 'mat.', | ||
afternoon: 'ap.m.', | ||
evening: 'soir', | ||
night: 'mat.' | ||
}, | ||
abbreviated: { | ||
am: 'AM', | ||
pm: 'PM', | ||
midnight: 'minuit', | ||
noon: 'midi', | ||
morning: 'matin', | ||
afternoon: 'après-midi', | ||
evening: 'soir', | ||
night: 'matin' | ||
}, | ||
wide: { | ||
am: 'AM', | ||
pm: 'PM', | ||
midnight: 'minuit', | ||
noon: 'midi', | ||
morning: 'du matin', | ||
afternoon: 'de l’après-midi', | ||
evening: 'du soir', | ||
night: 'du matin' | ||
} | ||
|
||
return number + 'e' | ||
} | ||
|
||
function ordinalNumber (dirtyNumber, dirtyOptions) { | ||
var number = Number(dirtyNumber) | ||
|
||
var options = dirtyOptions || {} | ||
var unit = options.unit ? String(options.unit) : null | ||
var unit = String(options.unit) | ||
var suffix | ||
|
||
if (unit === 'isoWeek' || unit === 'week') { | ||
return feminineOrdinalNumber(number) | ||
if (number === 0) { | ||
return number | ||
} | ||
|
||
if (unit === 'day' && number === 1) { | ||
suffix = 'er' | ||
} else { | ||
if (number === 1) { | ||
suffix = 'ère' | ||
} else { | ||
suffix = 'ème' | ||
} | ||
} | ||
|
||
return masculineOrdinalNumber(number) | ||
return number + suffix | ||
} | ||
|
||
var localize = { | ||
ordinalNumber: ordinalNumber, | ||
weekday: buildLocalizeFn(weekdayValues, 'long'), | ||
weekdays: buildLocalizeArrayFn(weekdayValues, 'long'), | ||
month: buildLocalizeFn(monthValues, 'long'), | ||
months: buildLocalizeArrayFn(monthValues, 'long'), | ||
timeOfDay: timeOfDay, | ||
timesOfDay: buildLocalizeArrayFn(timeOfDayValues, 'long') | ||
|
||
era: buildLocalizeFn({ | ||
values: eraValues, | ||
defaultWidth: 'wide' | ||
}), | ||
|
||
quarter: buildLocalizeFn({ | ||
values: quarterValues, | ||
defaultWidth: 'wide', | ||
argumentCallback: function (quarter) { | ||
return Number(quarter) - 1 | ||
} | ||
}), | ||
|
||
month: buildLocalizeFn({ | ||
values: monthValues, | ||
defaultWidth: 'wide' | ||
}), | ||
|
||
day: buildLocalizeFn({ | ||
values: dayValues, | ||
defaultWidth: 'wide' | ||
}), | ||
|
||
dayPeriod: buildLocalizeFn({ | ||
values: dayPeriodValues, | ||
defaultWidth: 'wide' | ||
}) | ||
} | ||
|
||
export default localize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,112 @@ | ||
import buildMatchFn from '../../../_lib/buildMatchFn/index.js' | ||
import buildParseFn from '../../../_lib/buildParseFn/index.js' | ||
import buildMatchPatternFn from '../../../_lib/buildMatchPatternFn/index.js' | ||
import parseDecimal from '../../../_lib/parseDecimal/index.js' | ||
import buildMatchFn from '../../../_lib/buildMatchFn/index.js' | ||
|
||
var matchOrdinalNumbersPattern = /^(\d+)(e|er|ère|ème|ième)?/i | ||
var matchOrdinalNumberPattern = /^(\d+)(e|er|ère|ème|ième)?/i | ||
var parseOrdinalNumberPattern = /\d+/i | ||
|
||
var matchWeekdaysPatterns = { | ||
narrow: /^(di|lu|ma|me|je|ve|sa)/i, | ||
short: /^(dim|lun|mar|mer|jeu|ven|sam)/i, | ||
long: /^(dimanche|lundi|mardi|mercredi|jeudi|vendredi|samedi)/i | ||
var matchEraPatterns = { | ||
narrow: /^(av\.J\.C|ap\.J\.C|ap\.J\.-C)/i, | ||
abbreviated: /^(av\.J\.-C|av\.J-C|apr\.J\.-C|apr\.J-C|ap\.J-C)/i, | ||
wide: /^(avant Jésus-Christ|après Jésus-Christ)/i | ||
} | ||
|
||
var parseWeekdayPatterns = { | ||
any: [/^d/i, /^l/i, /^ma/i, /^me/i, /^j/i, /^v/i, /^s/i] | ||
var parseEraPatterns = { | ||
any: [/^av/i, /^ap/i] | ||
} | ||
|
||
var matchMonthsPatterns = { | ||
short: /^(jan|fév|mar|avr|mai|juin|juil|aoû|sep|oct|nov|déc)/i, | ||
long: /^('janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre')/i | ||
var matchQuarterPatterns = { | ||
narrow: /^[1234]/i, | ||
abbreviated: /^t[1234]/i, | ||
wide: /^[1234](er|ème)? trimestre/i | ||
} | ||
var parseQuarterPatterns = { | ||
any: [/1/i, /2/i, /3/i, /4/i] | ||
} | ||
|
||
var matchMonthPatterns = { | ||
narrow: /^[jfmasond]/i, | ||
abbreviated: /^(janv|févr|mars|avr|mai|juin|juill|juil|août|sept|oct|nov|déc)/i, | ||
wide: /^(janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)/i | ||
} | ||
var parseMonthPatterns = { | ||
any: [/^ja/i, /^f/i, /^mar/i, /^av/i, /^mai$/i, /^juin/i, /^juil/i, /^ao/i, /^s/i, /^o/i, /^n/i, /^d/i] | ||
narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i], | ||
any: [/^ja/i, /^f/i, /^mar/i, /^av/i, /^ma/i, /^jui/i, /^juil/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i] | ||
} | ||
|
||
var matchTimesOfDayPatterns = { | ||
short: /^(am|pm)/i, | ||
long: /^([ap]\.?\s?m\.?)/i | ||
var matchDayPatterns = { | ||
narrow: /^[lmjvsd]/i, | ||
short: /^(di|lu|ma|me|je|ve|sa)/i, | ||
abbreviated: /^(dim|lun|mar|mer|jeu|ven|sam)/i, | ||
wide: /^(dimanche|lundi|mardi|mercredi|jeudi|vendredi|samedi)/i | ||
} | ||
var parseDayPatterns = { | ||
narrow: [/^d/i, /^l/i, /^m/i, /^j/i, /^v/i, /^s/i], | ||
any: [/^di/i, /^lu/i, /^ma/i, /^me/i, /^je/i, /^ve/i, /^sa/i] | ||
} | ||
|
||
var parseTimeOfDayPatterns = { | ||
any: [/^a/i, /^p/i] | ||
// those have to be checked | ||
var matchDayPeriodPatterns = { | ||
narrow: /^(am|pm|minuit|midi|mat|ap\.m\.|soir)/i, | ||
any: /^(am|pm|(du|de l') (matin|après-midi|soir))/i | ||
} | ||
var parseDayPeriodPatterns = { | ||
any: { | ||
am: /^am/i, | ||
pm: /^pm/i, | ||
midnight: /^mi/i, | ||
noon: /^mi/i, | ||
morning: /mat/i, | ||
afternoon: /ap/i, | ||
evening: /soir/i, | ||
night: /mat/i | ||
} | ||
} | ||
|
||
var match = { | ||
ordinalNumbers: buildMatchPatternFn(matchOrdinalNumbersPattern), | ||
ordinalNumber: parseDecimal, | ||
weekdays: buildMatchFn(matchWeekdaysPatterns, 'long'), | ||
weekday: buildParseFn(parseWeekdayPatterns, 'any'), | ||
months: buildMatchFn(matchMonthsPatterns, 'long'), | ||
month: buildParseFn(parseMonthPatterns, 'any'), | ||
timesOfDay: buildMatchFn(matchTimesOfDayPatterns, 'long'), | ||
timeOfDay: buildParseFn(parseTimeOfDayPatterns, 'any') | ||
ordinalNumber: buildMatchPatternFn({ | ||
matchPattern: matchOrdinalNumberPattern, | ||
parsePattern: parseOrdinalNumberPattern, | ||
valueCallback: function (value) { | ||
return parseInt(value, 10) | ||
} | ||
}), | ||
|
||
era: buildMatchFn({ | ||
matchPatterns: matchEraPatterns, | ||
defaultMatchWidth: 'wide', | ||
parsePatterns: parseEraPatterns, | ||
defaultParseWidth: 'any' | ||
}), | ||
|
||
quarter: buildMatchFn({ | ||
matchPatterns: matchQuarterPatterns, | ||
defaultMatchWidth: 'wide', | ||
parsePatterns: parseQuarterPatterns, | ||
defaultParseWidth: 'any', | ||
valueCallback: function (index) { | ||
return index + 1 | ||
} | ||
}), | ||
|
||
month: buildMatchFn({ | ||
matchPatterns: matchMonthPatterns, | ||
defaultMatchWidth: 'wide', | ||
parsePatterns: parseMonthPatterns, | ||
defaultParseWidth: 'any' | ||
}), | ||
|
||
day: buildMatchFn({ | ||
matchPatterns: matchDayPatterns, | ||
defaultMatchWidth: 'wide', | ||
parsePatterns: parseDayPatterns, | ||
defaultParseWidth: 'any' | ||
}), | ||
|
||
dayPeriod: buildMatchFn({ | ||
matchPatterns: matchDayPeriodPatterns, | ||
defaultMatchWidth: 'any', | ||
parsePatterns: parseDayPeriodPatterns, | ||
defaultParseWidth: 'any' | ||
}) | ||
} | ||
|
||
export default match |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the code style issues: https://travis-ci.org/date-fns/date-fns/jobs/391123642#L487