goyave.dev/goyave/v5@v5.0.0-rc9.0.20240517145003-d3f977d0b9f3/lang/default.go (about)

     1  package lang
     2  
     3  var enUS = &Language{
     4  	name: "en-US",
     5  	lines: map[string]string{
     6  		"malformed-request":            "Malformed request",
     7  		"malformed-json":               "Malformed JSON",
     8  		"auth.invalid-credentials":     "Invalid credentials.",
     9  		"auth.no-credentials-provided": "Invalid or missing authentication header.",
    10  		"auth.jwt-invalid":             "Your authentication token is invalid.",
    11  		"auth.jwt-not-valid-yet":       "Your authentication token is not valid yet.",
    12  		"auth.jwt-expired":             "Your authentication token is expired.",
    13  	},
    14  	validation: validationLines{
    15  		rules: map[string]string{
    16  			"required":                           "The :field is required.",
    17  			"required.element":                   "The :field elements are required.",
    18  			"float32":                            "The :field must be numeric.",
    19  			"float32.element":                    "The :field elements must be numeric.",
    20  			"float64":                            "The :field must be numeric.",
    21  			"float64.element":                    "The :field elements must be numeric.",
    22  			"int":                                "The :field must be an integer.",
    23  			"int.element":                        "The :field elements must be integers.",
    24  			"int8":                               "The :field must be an integer.",
    25  			"int8.element":                       "The :field elements must be integers.",
    26  			"int16":                              "The :field must be an integer.",
    27  			"int16.element":                      "The :field elements must be integers.",
    28  			"int32":                              "The :field must be an integer.",
    29  			"int32.element":                      "The :field elements must be integers.",
    30  			"int64":                              "The :field must be an integer.",
    31  			"int64.element":                      "The :field elements must be integers.",
    32  			"uint":                               "The :field must be a positive integer.",
    33  			"uint.element":                       "The :field elements must be positive integers.",
    34  			"uint8":                              "The :field must be a positive integer.",
    35  			"uint8.element":                      "The :field elements must be positive integers.",
    36  			"uint16":                             "The :field must be a positive integer.",
    37  			"uint16.element":                     "The :field elements must be positive integers.",
    38  			"uint32":                             "The :field must be a positive integer.",
    39  			"uint32.element":                     "The :field elements must be positive integers.",
    40  			"uint64":                             "The :field must be a positive integer.",
    41  			"uint64.element":                     "The :field elements must be positive integers.",
    42  			"string":                             "The :field must be a string.",
    43  			"string.element":                     "The :field elements must be strings.",
    44  			"array":                              "The :field must be an array.",
    45  			"array.element":                      "The :field elements must be arrays.",
    46  			"min.string":                         "The :field must be at least :min characters.",
    47  			"min.numeric":                        "The :field must be at least :min.",
    48  			"min.array":                          "The :field must have at least :min items.",
    49  			"min.file":                           "The :field must be at least :min KiB.",
    50  			"min.object":                         "The :field must have at least :min fields.",
    51  			"min.string.element":                 "The :field elements must be at least :min characters.",
    52  			"min.numeric.element":                "The :field elements must be at least :min.",
    53  			"min.array.element":                  "The :field elements must have at least :min items.",
    54  			"min.object.element":                 "The :field elements must have at least :min fields.",
    55  			"max.string":                         "The :field may not have more than :max characters.",
    56  			"max.numeric":                        "The :field may not be greater than :max.",
    57  			"max.array":                          "The :field may not have more than :max items.",
    58  			"max.file":                           "The :field may not be greater than :max KiB.",
    59  			"max.object":                         "The :field may not have more than :max fields.",
    60  			"max.string.element":                 "The :field elements may not have more than :max characters.",
    61  			"max.numeric.element":                "The :field elements may not be greater than :max.",
    62  			"max.array.element":                  "The :field elements may not have more than :max items.",
    63  			"max.object.element":                 "The :field elements may not have more than :max fields.",
    64  			"between.string":                     "The :field must be between :min and :max characters.",
    65  			"between.numeric":                    "The :field must be between :min and :max.",
    66  			"between.array":                      "The :field must have between :min and :max items.",
    67  			"between.object":                     "The :field must have between :min and :max fields.",
    68  			"between.file":                       "The :field must be between :min and :max KiB.",
    69  			"between.string.element":             "The :field elements must be between :min and :max characters.",
    70  			"between.numeric.element":            "The :field elements must be between :min and :max.",
    71  			"between.array.element":              "The :field elements must have between :min and :max items.",
    72  			"between.object.element":             "The :field elements must have between :min and :max fields.",
    73  			"greater_than.string":                "The :field must be longer than the :other.",
    74  			"greater_than.numeric":               "The :field must be greater than the :other.",
    75  			"greater_than.array":                 "The :field must have more items than the :other.",
    76  			"greater_than.file":                  "The :field must be larger than the :other.",
    77  			"greater_than.object":                "The :field must have more fields than the :other.",
    78  			"greater_than.string.element":        "The :field elements must be longer than the :other.",
    79  			"greater_than.numeric.element":       "The :field elements must be greater than the :other.",
    80  			"greater_than.array.element":         "The :field elements must have more items than the :other.",
    81  			"greater_than.object.element":        "The :field elements must have more fields than the :other.",
    82  			"greater_than_equal.string":          "The :field must be longer or have the same length as the :other.",
    83  			"greater_than_equal.numeric":         "The :field must be greater or equal to the :other.",
    84  			"greater_than_equal.array":           "The :field must have more or the same amount of items as the :other.",
    85  			"greater_than_equal.file":            "The :field must be the same size or larger than the :other.",
    86  			"greater_than_equal.object":          "The :field must have at least as many fields as the :other.",
    87  			"greater_than_equal.string.element":  "The :field elements must be longer or have the same length as the :other.",
    88  			"greater_than_equal.numeric.element": "The :field elements must be greater or equal to the :other.",
    89  			"greater_than_equal.array.element":   "The :field elements must have more or the same amount of items as the :other.",
    90  			"greater_than_equal.object.element":  "The :field elements must have at least as many fields as the :other.",
    91  			"lower_than.string":                  "The :field must be shorter than the :other.",
    92  			"lower_than.numeric":                 "The :field must be lower than the :other.",
    93  			"lower_than.array":                   "The :field must have less items than the :other.",
    94  			"lower_than.file":                    "The :field must be smaller than the :other.",
    95  			"lower_than.object":                  "The :field must have less fields than the :other.",
    96  			"lower_than.string.element":          "The :field elements must be shorter than the :other.",
    97  			"lower_than.numeric.element":         "The :field elements must be lower than the :other.",
    98  			"lower_than.array.element":           "The :field elements must have less items than the :other.",
    99  			"lower_than.object.element":          "The :field elements must have less fields than the :other.",
   100  			"lower_than_equal.string":            "The :field must be shorter or have the same length as the :other.",
   101  			"lower_than_equal.numeric":           "The :field must be lower or equal to the :other.",
   102  			"lower_than_equal.array":             "The :field must have less or the same amount of items as the :other.",
   103  			"lower_than_equal.file":              "The :field must be the same size or smaller than the :other.",
   104  			"lower_than_equal.object":            "The :field must have at most as many fields as the :other.",
   105  			"lower_than_equal.string.element":    "The :field elements must be shorter or have the same length as the :other.",
   106  			"lower_than_equal.numeric.element":   "The :field elements must be lower or equal to the :other.",
   107  			"lower_than_equal.array.element":     "The :field elements must have less or the same amount of items as the :other.",
   108  			"lower_than_equal.object.element":    "The :field elements must have at most as many fields as the :other.",
   109  			"distinct":                           "The :field must have only distinct values.",
   110  			"distinct.element":                   "The :field elements must have only distinct values.",
   111  			"digits":                             "The :field must be digits only.",
   112  			"digits.element":                     "The :field elements must be digits only.",
   113  			"regex":                              "The :field format is invalid.",
   114  			"regex.element":                      "The :field element format is invalid.",
   115  			"email":                              "The :field must be a valid email address.",
   116  			"email.element":                      "The :field elements must be valid email addresses.",
   117  			"size.string":                        "The :field must be exactly :value characters-long.",
   118  			"size.numeric":                       "The :field must be exactly :value.",
   119  			"size.array":                         "The :field must contain exactly :value items.",
   120  			"size.file":                          "The :field must be exactly :value KiB.",
   121  			"size.object":                        "The :field must have exactly :value fields.",
   122  			"size.string.element":                "The :field elements must be exactly :value characters-long.",
   123  			"size.numeric.element":               "The :field elements must be exactly :value.",
   124  			"size.array.element":                 "The :field elements must contain exactly :value items.",
   125  			"size.object.element":                "The :field elements must have exactly :value fields.",
   126  			"alpha":                              "The :field may only contain letters.",
   127  			"alpha.element":                      "The :field elements may only contain letters.",
   128  			"alpha_dash":                         "The :field may only contain letters, numbers, dashes and underscores.",
   129  			"alpha_dash.element":                 "The :field elements may only contain letters, numbers, dashes and underscores.",
   130  			"alpha_num":                          "The :field may only contain letters and numbers.",
   131  			"alpha_num.element":                  "The :field elements may only contain letters and numbers.",
   132  			"starts_with":                        "The :field must start with one of the following values: :values.",
   133  			"starts_with.element":                "The :field elements must start with one of the following values: :values.",
   134  			"ends_with":                          "The :field must end with one of the following values: :values.",
   135  			"ends_with.element":                  "The :field elements must end with one of the following values: :values.",
   136  			"in":                                 "The :field must have one of the following values: :values.",
   137  			"in.element":                         "The :field elements must have one of the following values: :values.",
   138  			"not_in":                             "The :field must not have one of the following values: :values.",
   139  			"not_in.element":                     "The :field elements must not have one of the following values: :values.",
   140  			"in_field":                           "The :field must exist in the :other.",
   141  			"in_field.element":                   "The :field elements must exist in the :other.",
   142  			"not_in_field":                       "The :field must not exist in the :other.",
   143  			"not_in_field.element":               "The :field elements must not exist in the :other.",
   144  			"timezone":                           "The :field must be a valid time zone.",
   145  			"timezone.element":                   "The :field elements must be valid time zones.",
   146  			"ip":                                 "The :field must be a valid IP address.",
   147  			"ip.element":                         "The :field elements must be valid IP addresses.",
   148  			"ipv4":                               "The :field must be a valid IPv4 address.",
   149  			"ipv4.element":                       "The :field elements must be valid IPv4 addresses.",
   150  			"ipv6":                               "The :field must be a valid IPv6 address.",
   151  			"ipv6.element":                       "The :field elements must be valid IPv6 addresses.",
   152  			"json":                               "The :field must be a valid JSON string.",
   153  			"json.element":                       "The :field elements must be valid JSON strings.",
   154  			"url":                                "The :field must be a valid URL.",
   155  			"url.element":                        "The :field elements must be valid URLs.",
   156  			"uuid":                               "The :field must be a valid UUID.",
   157  			"uuid.element":                       "The :field elements must be valid UUIDs.",
   158  			"bool":                               "The :field must be a boolean.",
   159  			"bool.element":                       "The :field elements must be booleans.",
   160  			"same":                               "The :field and the :other must match.",
   161  			"same.element":                       "The :field elements and the :other must match.",
   162  			"different":                          "The :field and the :other must be different.",
   163  			"different.element":                  "The :field elements and the :other must be different.",
   164  			"file":                               "The :field must be a file.",
   165  			"mime":                               "The :field must be a file of type: :values.",
   166  			"image":                              "The :field must be an image.",
   167  			"extension":                          "The :field must be a file with one of the following extensions: :values.",
   168  			"file_count":                         "The :field must have exactly :value file(s).",
   169  			"min_file_count":                     "The :field must have at least :value file(s).",
   170  			"max_file_count":                     "The :field may not have more than :value file(s).",
   171  			"file_count_between":                 "The :field must have between :min and :max files.",
   172  			"date":                               "The :field is not a valid date.",
   173  			"date.element":                       "The :field elements are not valid dates.",
   174  			"before":                             "The :field must be a date before :date.",
   175  			"before.element":                     "The :field elements must be dates before :date.",
   176  			"before_equal":                       "The :field must be a date before or equal to :date.",
   177  			"before_equal.element":               "The :field must be dates before or equal to :date.",
   178  			"after":                              "The :field must be a date after :date.",
   179  			"after.element":                      "The :field elements must be dates after :date.",
   180  			"after_equal":                        "The :field must be a date after or equal to :date.",
   181  			"after_equal.element":                "The :field elements must be dates after or equal to :date.",
   182  			"date_equals":                        "The :field must be a date equal to :date.",
   183  			"date_equals.element":                "The :field elements must be dates equal to :date.",
   184  			"object":                             "The :field must be an object.",
   185  			"object.element":                     "The :field elements must be objects.",
   186  			"unique":                             "The :field has already been taken.",
   187  			"unique.element":                     "The :field element value has already been taken.",
   188  			"exists":                             "The :field does not exist.",
   189  			"exists.element":                     "The :field element value does not exist.",
   190  		},
   191  		fields: map[string]string{
   192  			"":        "body",
   193  			"email":   "email address",
   194  			"perPage": "number of records per page",
   195  			"*":       "object property",
   196  		},
   197  	},
   198  }
   199  
   200  // SetDefaultLine set the language line identified by the given key in the
   201  // default "en-US" language.
   202  // Values set this way can be overridden by language files.
   203  func SetDefaultLine(key, line string) {
   204  	enUS.lines[key] = line
   205  }
   206  
   207  // SetDefaultValidationRule set the validation error message for the rule identified by
   208  // the given key in the default "en-US" language.
   209  // Values set this way can be overridden by language files.
   210  func SetDefaultValidationRule(key, line string) {
   211  	enUS.validation.rules[key] = line
   212  }
   213  
   214  // SetDefaultFieldName set the field name used in validation error message placeholders
   215  // for the given field in the default "en-US" language.
   216  // Values set this way can be overridden by language files.
   217  func SetDefaultFieldName(field, name string) {
   218  	enUS.validation.fields[field] = name
   219  }