en.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import formatTimeToString from '../utils/formatTimeToString'
  2. const general = {
  3. timeFormats: {
  4. days: {
  5. 1: () => `day`,
  6. 2: () => `days`,
  7. },
  8. hours: {
  9. 1: () => `hour`,
  10. 2: () => `hours`,
  11. },
  12. minutes: {
  13. 1: () => `minute`,
  14. 2: () => `minutes`,
  15. },
  16. seconds: {
  17. 1: () => `second`,
  18. 2: () => `seconds`,
  19. },
  20. },
  21. functionWords: {
  22. and: () => `and`,
  23. },
  24. errors: {
  25. turnstile: {
  26. unavailable: () => `cannot connect to Turnstile. please try again.`,
  27. noToken: () => `Turnstile token was not provided. please try again.`,
  28. invalidResponse: () => `invalid Turnstile response. please try again.`,
  29. keyUsedOrExpired: () => `Turnstile key already used or expired. please try again.`
  30. },
  31. },
  32. }
  33. export default {
  34. emails: {
  35. auth: {
  36. subject: () => `login link`,
  37. text: (details) => `
  38. hi!
  39. you can login using the following code: ${details?.code}
  40. or the following link: ${details?.link}
  41. if you did not request this email, feel free to ignore it.
  42. meteostanica
  43. `,
  44. },
  45. },
  46. auth: {
  47. errors: {
  48. invalidEmail: () => `you need to provide a valid email.`,
  49. noVerificationToken: () => `verification token was not provided. please try again.`,
  50. verificationTokenUsedOrExpired: () => `verification token already used or expired. please try again.`,
  51. invalidVerificationCode: () => `invalid verification code. please try again.`,
  52. loginNeeded: () => `please log in first.`,
  53. ratelimits: {
  54. email: (details) => {
  55. if (!Number.parseInt(details?.duration)) return `too many requests for this email. try again later.`
  56. return `too many requests for this email. try again in ${formatTimeToString(general.timeFormats, general.functionWords.and(), details?.duration * 1000)}.`
  57. },
  58. ip: (details) => {
  59. if (!Number.parseInt(details?.duration)) return `you made too many requests. try again later.`
  60. return `you made too many requests. try again in ${formatTimeToString(general.timeFormats, general.functionWords.and(), details?.duration * 1000)}.`
  61. },
  62. code: () => `you entered too many wrong codes. you need to request a new verification.`,
  63. },
  64. turnstile: general.errors.turnstile,
  65. },
  66. },
  67. settings: {
  68. errors: {
  69. invalidEmail: () => `you need to provide a valid email.`,
  70. emailTaken: (details) => `a user with the provided email (${details?.newEmail}) already exists.`,
  71. turnstile: general.errors.turnstile,
  72. },
  73. },
  74. stations: {
  75. errors: {
  76. noName: () => `you need to provide a name.`,
  77. invalidOwner: () => `you need to provide a valid owner email.`,
  78. ownerUserNotFound: (details) => `a user with the provided email (${details?.newOwnerEmail}) does not exist.`,
  79. turnstile: general.errors.turnstile,
  80. },
  81. },
  82. websocket: {
  83. keepalive: () => `free ferris`,
  84. dataSaved: (details) => `successfully saved data for ${details?.meteostanica?.name}`,
  85. errors: {
  86. missingFields: () => `missing required fields: indoorTemp, indoorPressure, indoorHumidity, indoorAltitude, outdoorConnected, outdoorTemp, outdoorPressure, outdoorHumidity, outdoorAltitude`,
  87. invalidKey: (details) => `invalid station websocket key (${details.key}) provided`,
  88. },
  89. }
  90. }